—————————————– Analysis:
cor(df$Abs, df$MathGrade, method = "pearson")
## [1] -0.08999937
cor.test(df$Abs, df$MathGrade)
##
## Pearson's product-moment correlation
##
## data: df$Abs and df$MathGrade
## t = -3.4315, df = 1442, p-value = 0.0006171
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.14093090 -0.03859271
## sample estimates:
## cor
## -0.08999937
Absence:
regAbs = lm(MathGrade ~ Abs, data = df)
summary(regAbs)
##
## Call:
## lm(formula = MathGrade ~ Abs, data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -58.528 -12.306 3.082 16.467 33.802
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 60.75040 0.80189 75.759 < 2e-16 ***
## Abs -0.11099 0.03234 -3.432 0.000617 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 20.13 on 1442 degrees of freedom
## Multiple R-squared: 0.0081, Adjusted R-squared: 0.007412
## F-statistic: 11.78 on 1 and 1442 DF, p-value: 0.0006171
Years of exp:
regYofExp= lm(MathGrade ~ YofExp, data = df); table(df$YofExp)
##
## 2 3 4
## 318 524 602
summary(regYofExp)
##
## Call:
## lm(formula = MathGrade ~ YofExp, data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -62.643 -11.664 3.316 15.357 37.316
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 74.6032 2.2193 33.62 < 2e-16 ***
## YofExp -4.9799 0.6748 -7.38 2.66e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 19.84 on 1442 degrees of freedom
## Multiple R-squared: 0.03639, Adjusted R-squared: 0.03573
## F-statistic: 54.46 on 1 and 1442 DF, p-value: 2.664e-13
Sex:
t.test(MathGrade ~ Sex, df, var.equal=TRUE)
##
## Two Sample t-test
##
## data: MathGrade by Sex
## t = 15.936, df = 1442, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 15.62751 20.01490
## sample estimates:
## mean in group Female mean in group Male
## 71.87733 54.05613
regSex= lm(MathGrade ~ as.factor(Sex), data = df)
summary(regSex)
##
## Call:
## lm(formula = MathGrade ~ as.factor(Sex), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -69.877 -10.056 3.944 12.123 37.944
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 71.8773 0.9622 74.70 <2e-16 ***
## as.factor(Sex)Male -17.8212 1.1183 -15.94 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 18.63 on 1442 degrees of freedom
## Multiple R-squared: 0.1497, Adjusted R-squared: 0.1491
## F-statistic: 253.9 on 1 and 1442 DF, p-value: < 2.2e-16
Qualification:
t.test(MathGrade ~ Qual, df, var.equal=TRUE)
##
## Two Sample t-test
##
## data: MathGrade by Qual
## t = -5.2625, df = 1442, p-value = 1.635e-07
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -8.489852 -3.879262
## sample estimates:
## mean in group Doc mean in group Master
## 54.22139 60.40595
regQual= lm(MathGrade ~ as.factor(Qual), data = df)
summary(regQual)
##
## Call:
## lm(formula = MathGrade ~ as.factor(Qual), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -58.406 -11.406 3.594 15.779 37.779
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 54.2214 0.9983 54.313 < 2e-16 ***
## as.factor(Qual)Master 6.1846 1.1752 5.263 1.64e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 20.02 on 1442 degrees of freedom
## Multiple R-squared: 0.01884, Adjusted R-squared: 0.01816
## F-statistic: 27.69 on 1 and 1442 DF, p-value: 1.635e-07
class time:
t.test(MathGrade ~ ClassTime, df, var.equal=TRUE)
##
## Two Sample t-test
##
## data: MathGrade by ClassTime
## t = -1.8937, df = 1442, p-value = 0.05847
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -4.14536402 0.07302844
## sample estimates:
## mean in group Evening mean in group Morning
## 57.50820 59.54436
regClass= lm(MathGrade ~ as.factor(ClassTime), data = df)
summary(regClass)
##
## Call:
## lm(formula = MathGrade ~ as.factor(ClassTime), data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -57.544 -12.508 3.456 16.456 34.492
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 57.5082 0.8172 70.376 <2e-16 ***
## as.factor(ClassTime)Morning 2.0362 1.0752 1.894 0.0585 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 20.18 on 1442 degrees of freedom
## Multiple R-squared: 0.002481, Adjusted R-squared: 0.001789
## F-statistic: 3.586 on 1 and 1442 DF, p-value: 0.05847
all variables:
regAll = lm(MathGrade ~ Abs + YofExp + as.factor(Qual) + as.factor(Sex), data = df)
summary(regAll)
##
## Call:
## lm(formula = MathGrade ~ Abs + YofExp + as.factor(Qual) + as.factor(Sex),
## data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -71.814 -9.408 4.042 12.206 39.123
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 76.71558 2.54962 30.089 < 2e-16 ***
## Abs -0.07929 0.02994 -2.648 0.00819 **
## YofExp -1.13162 0.69456 -1.629 0.10348
## as.factor(Qual)Master -0.47972 1.18166 -0.406 0.68483
## as.factor(Sex)Male -17.00885 1.27924 -13.296 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 18.59 on 1439 degrees of freedom
## Multiple R-squared: 0.1555, Adjusted R-squared: 0.1532
## F-statistic: 66.25 on 4 and 1439 DF, p-value: < 2.2e-16