Please do this task by R. a) Revise the simulation shown in the lecture with the...

60.1K

Verified Solution

Question

Basic Math

Please do this task by R.

a) Revise the simulation shown in the lecture with the aim ofconstructing the empirical sampling distribution of beta_hat, basedon 5000 trials.

b) According to the lecture, the mean of that histogram issupposed to be approximately equal to the true slope. Is it? Showcode.

c) According to the lecture, the standard deviation of thathistogram is supposed to be approximately equal tosigma_eps/sqrt(Sxx). Is it? Show code.

d) According to the lecture, the distribution of the beta_hat issupposed to be normal with certain parameters. Use qqnorm() andabline() to confirm that it is normal.

not sure if this help or not,

n = 10

n.trial = 64

x = c(1:n)

y_true = 10 + 2*x

sigma_eps = 15

par(mfrow=c(8,8),mar=c(0,0,0,0))

set.seed(123)

for(trial in 1:n.trial){

y_obs = y_true + rnorm(n,0,sigma_eps)

lm.1 = lm(y_obs ~ x)

plot(x, y_obs)

abline(10,2, col=2)

abline(lm.1, col=4)

}

Answer & Explanation Solved by verified expert
3.6 Ratings (579 Votes)
a Observe that to change the simulation trials to 5000 timeswe just need to change the ntrial variable Changing its value to5000 will ensure that in the given code Also the for loop shouldbe changed    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students