In: Statistics and Probability
Using R and the data in the table below, perform the regression of D on C (i.e., report the regression equation).
C |
D |
3 |
2 |
6 |
7 |
8 |
5 |
9 |
4 |
1 |
0 |
3 |
4 |
Hint: The code to enter the vectors C and D into R is:
C <- c(3, 6, 8, 9, 1, 3)
D <- c(2, 7, 5, 4, 0, 4)
You must figure out how to obtain the regression equation from R. Enter the code below and write the regression equation using the output provided by R.
Code:
Regression equation (remember to use a hat when it is appropriate):
Solution: We need to obtain the regression equation of D on C. It would be of the form
Where is the predicted value of the response variable D, C is the given value of the explanatory variable.
Also, b0 is the y-intercept and b1 is the slope of the regression equation. They are given by the following formula--
where are the means of the response and explanatory variables.
The values of b0 and b1 from R-software are obtained as b0 = 1.067 and b1 = 0.520.
So, the regression equation obtained is = 1.067 + 0.520 C
Th code in R-software is:
C <- c(3, 6, 8, 9, 1, 3)
D <- c(2, 7, 5, 4, 0, 4)
lm(D~C)
The output of the code is attached as an image below: