\[\newcommand{\E}{\mathbb{E}}\]

For this problem, we’ll use the mtcars data. And in particular, we’ll run the following regression

\[ mpg = \beta_0 + \beta_1 cyl + \beta_2 disp + \beta_3 hp + U \] In class, we talked about using \(AIC\) (Akaike Information Criteria) as a way to choose between different models for prediction. Calculate \(AIC\) for this regression. Hint: \(k\) is equal to 4 in this problem

Rules:

To win



Solution below…















reg <- lm(mpg ~ cyl + disp + hp, data=mtcars)
Y <- mtcars$mpg
Yhat <- predict(reg)
Uhat <- Y-Yhat
ssr <- sum(Uhat^2)
k <- 4
n <- nrow(mtcars)
aic <- 2*k + n*log(ssr)
aic
## [1] 186.1099