In: Statistics and Probability
x | y |
14 | 50 |
10 | 55 |
12 | 54 |
11 | 56 |
10 | 58 |
9 | 59 |
6 | 61 |
4 | 62 |
1.What is the slope?
2. What is the intercept?
3. Using the prediction of x=11 what are the residuals?
4. The sum of squared residuals is 12.038 calculate the standar deviation of the regression
5. What is the test statistic?
Solution-:
By using R-software:
> x=c(14,10,12,11,10,9,6,4);x
[1] 14 10 12 11 10 9 6 4
> y=c(50,55,54,56,58,59,61,62);y
[1] 50 55 54 56 58 59 61 62
> #(1)and (2)
> fit=lm(y~x);fit
Call:
lm(formula = y ~ x)
Coefficients:
(Intercept) x
67.89 -1.16
> cr=coef(fit);cr
(Intercept) x
67.892361 -1.159722
> mcr=matrix(cr);mcr
[,1]
[1,] 67.892361
[2,] -1.159722
> a=mcr[1,1];a #Intercept
[1] 67.89236
> round(a,2)
[1] 67.89
> b=mcr[2,1];b #slope
[1] -1.159722
> round(b,2)
[1] -1.16
> esty=fitted(fit);esty
1 2 3 4 5 6 7 8
51.65625 56.29514 53.97569 55.13542 56.29514 57.45486 60.93403
63.25347
> #Or
> esty=67.89-1.16*x;esty # Regression equation
[1] 51.65 56.29 53.97 55.13 56.29 57.45 60.93 63.25
> d=y-esty
> d1=d^2
> SSE=sum(d1);SSE #Residual Sum of Square
[1] 12.0384
> round(SSE,3)
[1] 12.038
> #(3) When x=11
> #Residual=Actual Value-Predicted value
> Res=11-55.1357;Res
[1] -44.1357
> #(4) For Standard deviation of regression
> n=8 # (Total observation in data)
> SDreg=sqrt(SSE/(n-2));SDreg
[1] 1.416474
> round(SDreg,2)
[1] 1.42
R-Code:
x=c(14,10,12,11,10,9,6,4);x
y=c(50,55,54,56,58,59,61,62);y
#(1)and (2)
fit=lm(y~x);fit
cr=coef(fit);cr
mcr=matrix(cr);mcr
a=mcr[1,1];a #Intercept
round(a,2)
b=mcr[2,1];b #slope
round(b,2)
esty=fitted(fit);esty
#Or
esty=67.89-1.16*x;esty # Regression equation
d=y-esty
d1=d^2
SSE=sum(d1);SSE #Residual Sum of Square
round(SSE,3)
#(3) When x=11
#Residual=Actual Value-Predicted value
Res=11-55.1357;Res
#(4) For Standard deviation of regression
n=8 # (Total observation in data)
SDreg=sqrt(SSE/(n-2));SDreg
round(SDreg,2)