Hi! I know this is a complicated problem so really any insight or knowledge woul
ID: 3126627 • Letter: H
Question
Hi! I know this is a complicated problem so really any insight or knowledge would be helpful at this point. This is a problem in "R", particuarly R Studio. Thank you!
Create a simulated bivariate data set consisting of n=100 (x_i, y_i) pairs:
* Generate n random x-coordinates, x_im from N(0, 1).
* Generate n random errors, epsilon_i, from N(0, sigma), using sigma = 4.
Make a graph of the data and model.
Create a simulated bivariate data set consisting of n=100(Xi, yi) pairs: Generate n random x-coordinatesxi from N(0, 1) ·Generate n random errors, ei, from N(0, ), using = 4 . Sety, = 0 1Xi + €i , where 0-2, | 3, and €i ~ N(0, 4)·(That is, y is a linear function of X, plus some random noise.) (Now we have simulated data. We'll pretend that we don't know the true y-intercept/ 0-2, the true slope 1-3, the true = 4, or the true errors ei. All we know are the data, (xi, yi). We'll let linear regression estimate the coefficients.) Make a graph of the data and model: Make a scatterplot of the data, (xi, yi) Estimate a linear regression model of the form y, Pixi Display a summary of the model, check that the estimated coefficients are near the true 0-2 and 3 ·Add a solid black estimated regression line to the plot. · Add a dashed red true line(y = 2 + 3x) to the plot. . Add dotted blue 95% pointwise confidence bands that consist, for each prediction (xi, yi), of a vertical confidence interval around yi centered at (xi, yi): the formula is yi ± tn-2, 2s$, , where y, is the predicted y at x-xi (this is available in the model you calculated) th , the residual (this estimate of ei is available in the model you calculated) (this is an estimate of ) 2 (xi-i) tn-2,a/2 is the number that cuts off a right-tail area .025 from a Student's t distribution with n-2 degrees of freedom . Add a legend identifying each of the black, red, and blue lines.Explanation / Answer
Generating 100 random x-cordinates X_im from N(0,1)
x_im = rnorm(100,0,1)
Generating 100 random errors
epsilon = rnorm(100,0,4)
y = 2 + 3*x_im + epsilon
To make a graph and data of the model :
plot ( y ~ x_im) : To plot the data
model <- lm( y ~ x_im) : To estimate the linear regression model
sumry <- summary(lm(y~x_im) : to generate a summary output of the model
abline(model, col= Black) : to add the regression line to the plot
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.