Lucy D’Agostino McGowan
((4) in (1) in (2))
model1
?model2
?Analysis of Variance Table
Response: Weight
Df Sum Sq Mean Sq F value Pr(>F)
Length 1 6118739 6118739 3126.6 < 2e-16 ***
Width 1 110593 110593 56.5 7.4e-10 ***
Length:Width 1 314997 314997 161.0 < 2e-16 ***
Residuals 52 101765 1957
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Analysis of Variance Table
Response: Weight
Df Sum Sq Mean Sq F value Pr(>F)
Length 1 6118739 6118739 3289.64 < 2e-16 ***
Width 1 110593 110593 59.46 4.7e-10 ***
I(Length^2) 1 314899 314899 169.30 < 2e-16 ***
I(Width^2) 1 5381 5381 2.89 0.095 .
Length:Width 1 3482 3482 1.87 0.177
Residuals 50 93000 1860
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Analysis of Variance Table
Response: Weight
Df Sum Sq Mean Sq F value Pr(>F)
Length 1 6118739 6118739 3289.64 < 2e-16 ***
Width 1 110593 110593 59.46 4.7e-10 ***
I(Length^2) 1 314899 314899 169.30 < 2e-16 ***
I(Width^2) 1 5381 5381 2.89 0.095 .
Length:Width 1 3482 3482 1.87 0.177
Residuals 50 93000 1860
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
An easier way
Call:
lm(formula = Weight ~ Length + Width + Length * Width, data = Perch)
Residuals:
Min 1Q Median 3Q Max
-140.11 -12.23 1.23 8.49 181.41
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 113.935 58.784 1.94 0.058 .
Length -3.483 3.152 -1.10 0.274
Width -94.631 22.295 -4.24 9.1e-05 ***
Length:Width 5.241 0.413 12.69 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 44.2 on 52 degrees of freedom
Multiple R-squared: 0.985, Adjusted R-squared: 0.984
F-statistic: 1.11e+03 on 3 and 52 DF, p-value: <2e-16
Call:
lm(formula = Weight ~ Length + Width + Length * Width + I(Length^2) +
I(Width^2), data = Perch)
Residuals:
Min 1Q Median 3Q Max
-117.17 -11.90 2.82 11.56 157.60
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 156.349 61.415 2.55 0.014 *
Length -25.001 14.273 -1.75 0.086 .
Width 20.977 82.588 0.25 0.801
I(Length^2) 1.572 0.724 2.17 0.035 *
I(Width^2) 34.406 18.745 1.84 0.072 .
Length:Width -9.776 7.145 -1.37 0.177
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 43.1 on 50 degrees of freedom
Multiple R-squared: 0.986, Adjusted R-squared: 0.985
F-statistic: 705 on 5 and 50 DF, p-value: <2e-16
log()
in R
What I want you to remember
\[\log(\mathcal{L}) = -\frac{n}{2}[\log(SSE/n) ]+\textrm{some constant}\]
log()
in R
Application Exercise
Fit a model predicting GPA
using high school gpa (HSGPA
) and verbal SAT score (SATV
). Save this as model1
Fit a model predicting GPA
using high school gpa, verbal SAT score (SATV
), and math SAT score (SATM
). Save this as model2
.
Fit a model predicting GPA
using high school gpa, verbal SAT score (SATV
), math SAT score (SATM
), and number of humanities credits taken in high school (HU
). Save this as model3
.
Conduct an “nested F test” comparing Model 1 to Model 2. What are the null and alternative hypotheses? Is model 2 significantly better than model 1?
Conduct a “nested F test” comparing Model 2 to Model 3. What are the null and alternative hypotheses? Is model 3 significantly better than model 2?
Choose AIC or BIC to compare models 1, 2, and 3. Rank the models.
08:00