Confirmatory model selection

Instructions:

The variable names are also different here as examples are on different data to what you have. Results will also be different


The first step in confirmatory model selection is to work out what your H0 (null hypothesis) and H1 (alternative hypothesis) are.

Once you have worked this out you should run a linear model for each of these. You should know the code to do this by now. Make sure to save them as objects e.g. YourModelH0 <- lm(), because you will use them in other functions later.

Now you have your two models for H0 and H1, use the anova() function to compare them.

anova(YourModel1, YourModel2) 
## Analysis of Variance Table
## 
## Model 1: height ~ 1
## Model 2: height ~ type
##   Res.Df    RSS Df Sum of Sq      F  Pr(>F)  
## 1     29 293.44                              
## 2     28 242.08  1    51.352 5.9395 0.02141 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Hint: check the degrees of freedom to see if you put them in the right order. The degrees of freedom should make sense

Now you need to interpret the output. Below is an example from a different dataset.

Degrees of freedom HERE begins as: n (number of data points). But usually n-1

The columns are:

anova(YourModel1, YourModel2) 
## Analysis of Variance Table
## 
## Model 1: height ~ 1
## Model 2: height ~ type
##   Res.Df    RSS Df Sum of Sq      F  Pr(>F)  
## 1     29 293.44                              
## 2     28 242.08  1    51.352 5.9395 0.02141 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1