In: Statistics and Probability
Here are some test scores from eight students in a class such as yours:
Second Test Score: 158, 162, 144, 162, 136, 158, 175, 153
First Test Score: 145, 140, 145, 170, 145, 175, 170, 160
A.) Pick an explanatory variable, and explain your choice
B.) Using this data make a scatter plot
C.) Find the correlation, and graph the line of best fit on the scatter plot
a) Let Y : Second Test score .
X : First test score.
Since the second test score depends on first test score.
Hence first test score (X) is an explanatory variable or independent variable.
and second test score (Y) is an explained variable or dependent variable.
b) Scatter diagram
By using R
> x= c( 145,140,145,170,145,175,170,160)
> y=c(158,162,144,162,136,158,175,153)
> plot(x,y,xlab="First test score", ylab="Second test score",
main = "Scatter diagram")
c) By using R
> x= c( 145,140,145,170,145,175,170,160)
> y=c(158,162,144,162,136,158,175,153)
> r= cor(x,y)
> r
[1] 0.5194218
> line=lm(y~x)
> line
Call:
lm(formula = y ~ x)
Coefficients:
(Intercept) x
87.3063 0.4396
> coeff=coefficients(line)
> eq = paste0("y = ", round(coeff[2],1), "*x ","+",
round(coeff[1],1))
> eq
[1] "y = 0.4*x +87.3"
> data=data.frame(x,y)
> plot(data,main=eq)
> abline(line,col="red")
From R - output
The correlation coefficient between X and Y is 0.5194218.
and equation of line of best fit is Y = 0.4 *X + 87.3
Y-intercept = 87.3 and Slope of line = 0.4.