Consider the following data:
X |
Y |
1 | 13 |
3 | 10 |
5 | 9 |
5 | 5 |
6 | 3 |
x=c(1,3,5,5,6)
y=c(13,10,9,5,3)
# a) scatter plot
plot=plot(x,y)
#b)
> data=data.frame(x,y)
> data
x y
1 1 13
2 3 10
3 5 9
4 5 5
5 6 3
model=lm(y~x,data=data)
>model
Call:
lm(formula = y ~ x, data = data)
Coefficients:
(Intercept) x
15.250 -1.812
R_squared=summary(model)$r.squared
R_squared
[1] 0.8212891
correlation_coefficent=sqrt(R_squared)
correlation_coefficent
[1] 0.90625
here correlation coefficent is postive quantity hence it is postive and close to one
#c) our fitted model is Y^=15.250-1.812*x
x=4
y_pred=15.250-1.812*4
y_pred
[1] 8.002
here Y associated with x=4 is 8.002
Get Answers For Free
Most questions answered within 1 hours.