Question

Let X ∼ N(0, 1), ∼ N(0, 1). Let Y = 1.75 + 2X + ....

Let X ∼ N(0, 1), ∼ N(0, 1). Let Y = 1.75 + 2X + . Generate 100 samples for (X, Y ). Use the generated data to fit a linear regression. (a) Report the fitted coefficients and intercept. (b) Draw a scatter plot of (X, Y ). Add the fitted line and the real line to the scatter plot with different color.

Using R

Homework Answers

Answer #1

All R commands are shown in bold.

Generate 100 samples for (X, Y ).

x = rnorm(100)

e = rnorm(100)
y = 1.75 + 2 * x + e

Use the generated data to fit a linear regression.

model = lm(y~x)
model


Call:
lm(formula = y ~ x)

Coefficients:
(Intercept) x
1.763705 1.997952

(a)

fitted coefficients = 1.997952

intercept = 1.763705

(b)

Scatter plot of (X, Y ) is,

plot(x, y, pch = 16, col = "blue")

Add the fitted line and the real line to the scatter plot with different color.

abline(model, col = "red") #Fitted line

lines(x, 1.75 + 2 *x, col = "green") # Real line

Know the answer?
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
Similar Questions
Data Set: x y 0 4 2 2 2 0 5 -2 6 1 1. Find...
Data Set: x y 0 4 2 2 2 0 5 -2 6 1 1. Find intercept b0 2. Find slope B1 3. Find the best fitted linear regression equation 4.Graph observations 5.Graph the linear equation on the same plot 6. Find the coefficient of Determination r² 7. Find the linear correlation coefficient r 8.Interpret r (the correlation between x & y)
X Y 9 -2.8 4 3.1 6 -4.9 2 1.2 8 -5.9 The sample of five...
X Y 9 -2.8 4 3.1 6 -4.9 2 1.2 8 -5.9 The sample of five observations for the variables x and y has been collected . The least squares regression line for this sample is y = 4 − x.  Draw a scatter plot for this dataset and add the regression line.  In this diagram, indicate the five residuals of this linear regression .  Calculate the predicted value and the residual for the point (6, −.9).
Let x = day of observation and y = number of locusts per square meter during...
Let x = day of observation and y = number of locusts per square meter during a locust infestation in a region of North Africa. x 2 3 5 8 10 y 2 3 12 125 630 (a) Draw a scatter diagram of the (x, y) data pairs. Do you think a straight line will be a good fit to these data? Do the y values almost seem to explode as time goes on? No. A straight line does not...
Let x = day of observation and y = number of locusts per square meter during...
Let x = day of observation and y = number of locusts per square meter during a locust infestation in a region of North Africa. x 2 3 5 8 10 y 2 3 12 125 630 (a) Draw a scatter diagram of the (x, y) data pairs. Do you think a straight line will be a good fit to these data? Do the y values almost seem to explode as time goes on? No. A straight line does not...
Suppose that a researcher collected the following set of data on years of education (X) and...
Suppose that a researcher collected the following set of data on years of education (X) and number of children for a sample of married adults:                  X                  Y                     12                  2                 14                  1                 17                  0                 10                  3                  8                   5                  9                   3                 12                  4                 14                  2                 18                  0                 16                  2     Draw a scatter plot of the data. Write out the regression equation, then calculate and interpret the meaning of the...
Problem (9). Let R be the region enclosed by y = 2x, the x-axis, and x...
Problem (9). Let R be the region enclosed by y = 2x, the x-axis, and x = 2. Draw the solid and set-up an integral (or a sum of integrals) that computes the volume of the solid obtained by rotating R about: (a) the x-axis using disks/washers (b) the x-axis using cylindrical shells (c) the y-axis using disks/washer (d) the y-axis using cylindrical shells (e) the line x = 3 using disks/washers (f) the line y = 4 using cylindrical...
1. [10] Let ~x ∈ R n with ~x 6= ~0. For each ~y ∈ R...
1. [10] Let ~x ∈ R n with ~x 6= ~0. For each ~y ∈ R n , recall that perp~x(~y) = ~y − proj~x(~y). (a) Show that perp~x(~y + ~z) = perp~x(~y) + perp~x(~z) for all ~y, ~z ∈ R n . (b) Show that perp~x(t~y) = tperp~x(~y) for all ~y ∈ R n and t ∈ R. (c) Show that perp~x(perp~x(~y)) = perp~x(~y) for all ~y ∈ R n
Let f(x, y) = (2y-x^2)(y-2x^2) a. Show that f(x, y) has a stationary point at (0,...
Let f(x, y) = (2y-x^2)(y-2x^2) a. Show that f(x, y) has a stationary point at (0, 0) and calculate the discriminant at this point. b. Show that along any line through the origin, f(x, y) has a local minimum at (0, 0)
Find the equation of the tangent line y=mx+b y=e2x+2x at x=0 m=??? n=???
Find the equation of the tangent line y=mx+b y=e2x+2x at x=0 m=??? n=???
Let R be the region bounded by y = x2 + 1, y = 0, x...
Let R be the region bounded by y = x2 + 1, y = 0, x = 1, and x = 2. Graph the region R. Find the volume of the solid generated when R is revolved about the y-axis using (a) the Washer Method and (b) the Shell Method.