Codes anova test analysis deviance table model gamma
INFT13/71-326
Statistical Learning and Regression Models Indicative Solutions
Week 10Load some of the usual suspects:
| 8 | 10 | 14 | 65 | 70 | 75 | 80 | ||
|---|---|---|---|---|---|---|---|---|
| trees$Height | ||||||||
# Start with linear regression, but maybe some heteroskedasticity, so might need to switch to # Gamma model.
1
| 10 | 20 | 30 | 40 | 50 | 60 | 70 |
|---|
fitted(trees.lm)
| 0.1 | |||||||
|---|---|---|---|---|---|---|---|
| 0.0 | |||||||
| −0.1 | |||||||
| −0.2 | |||||||
| 10 | 20 | 30 | 40 | 50 | 60 | ||
fitted(trees.glm)
| trees$Volume | ||||||||
|---|---|---|---|---|---|---|---|---|
| 60 | ||||||||
| 50 | ||||||||
| 40 | ||||||||
| 30 | ||||||||
| 20 | ||||||||
| 10 | ||||||||
| 10 | 20 | 30 | 40 | 50 | 60 | 70 | ||
fitted(trees.lm)
| trees$Volume | |||||||
|---|---|---|---|---|---|---|---|
| 60 | |||||||
| 50 | |||||||
| 40 | |||||||
| 30 | |||||||
| 20 | |||||||
| 10 | |||||||
| 10 | 20 | 30 | 40 | 50 | 60 | ||
|
|---|
|
|---|
6
trees$Height
trees$Girth
|
|---|
|
||||
|---|---|---|---|---|
|
||||
| 1 2901.2 |
|
|||
|
||||
|
186.0 |
|
||
| ## Signif. codes: | ||||
## Df Deviance Resid. Df Resid. Dev F Pr(>F)
## NULL 30 8.3172
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
|
|||||
|---|---|---|---|---|---|
| Df Sum Sq Mean Sq | F value | ||||
|
|
||||
|
|
||||
| 26 | 185.9 | ||||
| ## Signif. codes: | |||||
trees.glmq2 <- glm(Volume~Height+Girth+I(Girth^2)+I(Height^2),family=Gamma(link="identity"),data=trees)
|
|||||
|---|---|---|---|---|---|
|
|||||
| Df Sum Sq Mean Sq | |||||
| 1 2901.2 |
|
||||
|
1 4783.0 | ||||
| ## I(Girth^2) | 1 | 235.9 | 235.9 | ||
| residuals(trees.lm1) | |||||
|---|---|---|---|---|---|
| −0.05 | |||||
| −0.15 | |||||
| 2.5 | 3.0 | 3.5 | 4.0 | ||
fitted(trees.lm1)
| −0.05 | |||||
|---|---|---|---|---|---|
| −0.15 | |||||
| 2.5 | 3.0 | 3.5 | 4.0 | ||
trees.glm1$linear.predictors
| abs(residuals(trees.lm1)) | 0.15 | ||||
|---|---|---|---|---|---|
| 0.10 | |||||
| 0.05 | |||||
| 0.00 | |||||
| 2.5 | 3.0 | 3.5 | 4.0 | ||
16
| 0.10 | |||||
|---|---|---|---|---|---|
| 0.05 | |||||
| 0.00 | |||||
| 2.5 | 3.0 | 3.5 | 4.0 | ||
| log(trees$Volume) | |||||
|---|---|---|---|---|---|
| 3.5 | |||||
| 3.0 | |||||
| 2.5 | |||||
| 2.5 | 3.0 | 3.5 | 4.0 | ||
18
| log(trees$Volume) | |||||
|---|---|---|---|---|---|
| 3.5 | |||||
| 3.0 | |||||
| 2.5 | |||||
| 2.5 | 3.0 | 3.5 | |||
## [1] 155.5867
trees.glm1$linear.predictors
|
|---|




