Lab-9 RMD
Lab-9 RMD
Maira Sulaimanova
2023-11-14
Class_Size <- c(23,19,30,22,23,29,35,36,33,25)
Test_Score <- c(430,430,333,410,390,377,325,310,328,385)
plot(Class_Size,Test_Score,xlab="class size",ylab="test score")
mean(Test_Score)
## [1] 371.8
var(Test_Score)
## [1] 2022.178
sd(Test_Score)
## [1] 44.96863
cov(Class_Size,Test_Score)
## [1] -254.2222
cor(Class_Size,Test_Score)
## [1] -0.953319
##
## Call:
## lm(formula = Test_Score ~ Class_Size)
##
## Residuals:
## Min 1Q Median 3Q Max
## -20.727 -4.665 -2.404 5.475 25.669
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 570.5994 22.7243 25.110 6.77e-09 ***
## Class_Size -7.2291 0.8096 -8.929 1.96e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 14.4 on 8 degrees of freedom
## Multiple R-squared: 0.9088, Adjusted R-squared: 0.8974
## F-statistic: 79.74 on 1 and 8 DF, p-value: 1.963e-05
plot(Test_Score ~ Class_Size)
abline(mod, col = "red")
library(AER)
##
## Attaching package: 'zoo'
data("CASchools")
income <- CASchools$income[1:10]
data_df <- data.frame(income, Test_Score)
summary(mod)
##
## Call:
## lm(formula = Test_Score ~ Class_Size)
##
## Residuals:
## Min 1Q Median 3Q Max
## -20.727 -4.665 -2.404 5.475 25.669
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 570.5994 22.7243 25.110 6.77e-09 ***
## Class_Size -7.2291 0.8096 -8.929 1.96e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 14.4 on 8 degrees of freedom
## Multiple R-squared: 0.9088, Adjusted R-squared: 0.8974
## F-statistic: 79.74 on 1 and 8 DF, p-value: 1.963e-05
cor(data_df$income, data_df$Test_Score)
## [1] 0.6083904
##
## Call:
## lm(formula = income ~ Test_Score, data = data_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.1394 -2.0373 -0.2803 0.8577 8.7266
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -12.57491 10.65244 -1.180 0.272
## Test_Score 0.06172 0.02846 2.168 0.062 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.84 on 8 degrees of freedom
## Multiple R-squared: 0.3701, Adjusted R-squared: 0.2914
## F-statistic: 4.701 on 1 and 8 DF, p-value: 0.06199
## R-squared: -7.860718