Question

R Programming

In this section, we will expand upon some of the ideas we have incorporated in the homework. For this entire problem, we will1. (a) Set the sample size to be n 25. Simulate 10,000 datasets (think for-loop),each time computing and storing the estimate

0 0
Add a comment Improve this question Transcribed image text
Answer #1

R Program

#Question a.

n=25
rep=10000
m1=numeric(rep)
m2=numeric(rep)
m3=numeric(rep)
m4=numeric(rep)

for(i in 1:rep)
{
x=rnorm(n,10,3)
m1[i]=mean(x)
m2[i]=median(x)
m3[i]=(quantile(x,.25)+quantile(x,.75))/2
m4[i]=x[1]
}

#Question b
## Bias, Variance & MSE of first estimator

bias_m1=mean(m1)-10
var_m1=var(m1)
mse_m1=mean((m1-10)*(m1-10))
bias_m1
var_m1
mse_m1

## Bias, Variance & MSE of second estimator

bias_m2=mean(m2)-10
var_m2=var(m2)
mse_m2=mean((m2-10)*(m2-10))
bias_m2
var_m2
mse_m2

## Bias, Variance & MSE of third estimator

bias_m3=mean(m3)-10
var_m3=var(m3)
mse_m3=mean((m3-10)*(m3-10))
bias_m3
var_m3
mse_m3

## Bias, Variance & MSE of fourth estimator

bias_m4=mean(m4)-10
var_m4=var(m4)
mse_m4=mean((m4-10)*(m4-10))
bias_m4
var_m4
mse_m4

#Question c.

boxplot(m1,m2,m3,m4,names=c("Mean","Q2",".5(Q1+Q3)","X1"))

#Question d.
boxplot(m1,m2,m3,names=c("Mean","Q2",".5(Q1+Q3)"))

Question e

The boxplot shows unbiasedness of all the estimators as the central is more or less
at 10. However, for mean, the variability is least as the length of the box is smallest.
But highest variability is observed for the Median based on the plot.

R Output

> #Question b
> ## Bias, Variance & MSE of first estimator
CN Mean Q2 .5(Q1+Q3) X1CN Mean Q2 .5(Q1+Q3)>bias_m1
[1] 0.003531876
> var_m1
[1] 0.3510436
> mse_m1
[1] 0.351021
>
> ## Bias, Variance & MSE of second estimator
>
> bias_m2=mean(m2)-10
> var_m2=var(m2)
> mse_m2=mean((m2-10)*(m2-10))
> bias_m2
[1] 0.003000309
> var_m2
[1] 0.5450123
> mse_m2
[1] 0.5449668
>
> ## Bias, Variance & MSE of third estimator
>
> bias_m3=mean(m3)-10
> var_m3=var(m3)
> mse_m3=mean((m3-10)*(m3-10))
> bias_m3
[1] 0.003185415
> var_m3
[1] 0.4346715
> mse_m3
[1] 0.4346382
>
> ## Bias, Variance & MSE of fourth estimator
>
> bias_m4=mean(m4)-10
> var_m4=var(m4)
> mse_m4=mean((m4-10)*(m4-10))
> bias_m4
[1] 0.01779539
> var_m4
[1] 9.257936
> mse_m4
[1] 9.257327
>


Add a comment
Know the answer?
Add Answer to:
R Programming In this section, we will expand upon some of the ideas we have incorporated...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 7. Section 6.4, Exercise 1 Let X. X be a random sample from the U(0,0) distribution, and let , 2X...

    7. Section 6.4, Exercise 1 Let X. X be a random sample from the U(0,0) distribution, and let , 2X and mx X, be estimators for 0. It is given that the mean and variance of oz are (a) Give an expression for the bias of cach of the two estimators. Are they unbiased? (b) Give an expression for the MSE of cach of the two estimators. (c) Com pute the MSE of each of the two ctrnators for n...

  • 1. Select all true statements about sample mean and sample median. A) When the population distribution...

    1. Select all true statements about sample mean and sample median. A) When the population distribution is skewed, sample mean is biased but sample median is an unbiased estimator of population mean. B) When the population distribution is symmetric, both mean and sample median are unbiased estimators of population mean. C) Sampling distribution of sample mean has a smaller standard error than sample median when population distribution is normal. D) Both mean and median are unbiased estimators of population mean...

  • 3. You have two independent random samples: XiXX from a population with mean In and variance σ2 a...

    3. You have two independent random samples: XiXX from a population with mean In and variance σ2 and Y, Y2, , , , , Y,n from a population with mean μ2 and variance σ2. Note that the two populations share a common variance. The two sample variances are Si for the first sample and Si for the second. We know that each of these is an unbiased estimator of the common population variance σ2, we also know that both of...

  • For a parametric model with distribution N(μ,02), we have: & variance = σ How can we...

    For a parametric model with distribution N(μ,02), we have: & variance = σ How can we use these formulas to explain why the sample mean is an unbiased and consistent estimator of the population mean?

  • This is related to Machine Learning Problem We have talked about the fact that the sample...

    This is related to Machine Learning Problem We have talked about the fact that the sample mean estimator X = 1 , X, is an unbiased estimator of the mean u for identically distributed X1, X2, ..., Xn: E(X) = p. The sample variance, on the other hand, is not an unbiased estimate of the true variance o2: for V = 12-1(X; - X), we get that E[V] = (1 - 02. Instead, the following bias-corrected sample variance estimator is...

  • Suppose you have a random sample {X1, X2, X3} of size n = 3. Consider the following three possible estimators for the p...

    Suppose you have a random sample {X1, X2, X3} of size n = 3. Consider the following three possible estimators for the population mean u and variance o2 Дi 3D (X1+ X2+ X3)/3 Ti2X1/4 X2/2 X3/4 Дз — (Х+ X,+ X3)/4 (a) What is the bias associated with each estimator? (b) What is the variance associated with each estimator? (c) Does the fact that Var(i3) < Var(1) contradict the statement that X is the minimum variance unbiased estimator? Why or...

  • 3. (5 marks) Let U be a random variable which has the continuous uniform distribution on the inte...

    3. (5 marks) Let U be a random variable which has the continuous uniform distribution on the interval I-1, 1]. Recall that this means the density function fu satisfies for(z-a: a.crwise. 1 u(z), -1ss1, a) Find thc cxpccted valuc and the variancc of U. We now consider estimators for the expected value of U which use a sample of size 2 Let Xi and X2 be independent random variables with the same distribution as U. Let X = (X1 +...

  • QUESTION 2 Let Xi.. Xn be a random sample from a N (μ, σ 2) distribution,...

    QUESTION 2 Let Xi.. Xn be a random sample from a N (μ, σ 2) distribution, and let S2 and Š-n--S2 be two estimators of σ2. Given: E (S2) σ 2 and V (S2) - ya-X)2 n-l -σ (a) Determine: E S2): (l) V (S2); and (il) MSE (S) (b) Which of s2 and S2 has a larger mean square error? (c) Suppose thatnis an estimator of e based on a random sample of size n. Another equivalent definition of...

  • SOLVE the following in R code: iid Let X1, , Xn ~ U (0,0). We are...

    SOLVE the following in R code: iid Let X1, , Xn ~ U (0,0). We are going to compare two estimators for θ: 01-2X, the method of moments estimator -maxX.... X1, the maximum likelihood estimator I. Generate 50,000 samples of size n-50 from U(0,5). For each sample compute both θ1 and 02 (Hint: You can use the R cornmand max (v) to find the maximum entry of a vector v). The results should be collected in two vectors of length...

  • QUESTION 21 If we change a 90% confidence interval estimate to a 99% confidence interval estimate...

    QUESTION 21 If we change a 90% confidence interval estimate to a 99% confidence interval estimate while holding sample size constant, we can expect a. the width of the confidence interval to increase. b. the width of the confidence interval to decrease. c. the width of the confidence interval to remain the same. d. the sample size to increase. QUESTION 22 Which one of the following is a correct statement about the probability distribution of a t random variable? a....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT