library(tidyverse)
library(Stat2Data)
library(skimr)

Exercise 3.1

  1. What would this tell you about a student who got perfect scores on the midterm and project? \[ \hat{Final}=11.0+0.53*(100)+1.20(30)=100 \]
  1. Michael got a grade of 87 on his midterm, 21 on the project, and an 80 on the final. Compute his residual and write a sentence to explain what that value means in Michael’s case. \[ \hat{Final}=11.0+0.53*(87)+1.2*(21)=82.31\\ Residual=80-82.31=-2.31 \]

Exercise 3.3

Does the prediction equation for final exam scored in 3.1 suggest that the project score has a stronger relationship with the final exam than the midterm exam? Explain why or why not.

Exercise 3.21

data(MathEnrollment)
skim(MathEnrollment)
## Skim summary statistics
##  n obs: 11 
##  n variables: 3 
## 
## ── Variable type:integer ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────
##  variable missing complete  n    mean    sd   p0    p25  p50    p75 p100
##     AYear       0       11 11 2006     3.32 2001 2003.5 2006 2008.5 2011
##      Fall       0       11 11  285.45 28.18  248  266    286  302    343
##    Spring       0       11 11  257.82 32.71  206  238    254  285.5  308
##      hist
##  ▇▃▃▇▃▃▃▇
##  ▇▁▅▅▇▁▁▂
##  ▅▂▁▇▁▂▇▂
mod = lm(Spring ~ Fall + AYear, data = MathEnrollment)
summary(mod)
## 
## Call:
## lm(formula = Spring ~ Fall + AYear, data = MathEnrollment)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -30.613 -23.022   5.416   7.541  55.357 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)
## (Intercept) -8743.3901  6141.5341  -1.424    0.192
## Fall           -0.2021     0.3589  -0.563    0.589
## AYear           4.5159     3.0492   1.481    0.177
## 
## Residual standard error: 31.09 on 8 degrees of freedom
## Multiple R-squared:  0.2773, Adjusted R-squared:  0.09663 
## F-statistic: 1.535 on 2 and 8 DF,  p-value: 0.2728
  1. What percent of the variability in spring enrollment is explained by the multiple regression model based on fall enrollment and academic year?
  1. Provide the ANOVA table for partitioning the total variability in spring enrollment based on this model and interpret the associated F-test.
anova(mod)
## Analysis of Variance Table
## 
## Response: Spring
##           Df Sum Sq Mean Sq F value Pr(>F)
## Fall       1  847.0  847.00  0.8763 0.3766
## AYear      1 2120.1 2120.06  2.1934 0.1769
## Residuals  8 7732.6  966.57
  1. Are the regression coefficients for both explanatory variables significantly different from zero? Provide appropriate hypotheses, test statisitics, and P-values in order to make your conclusion. \[ H_0:\beta_1=\beta_2=0\\ H_A:\beta_1\ne\beta_2 \]