# [R] Degrees of Freedom Not Allocated to Residuals in Reduced Model

wesman2k1 at aim.com wesman2k1 at aim.com
Wed Apr 21 21:50:52 CEST 2010

```
I am trying to test for fixed factor main effects in an unbalanced
mixed effects model but when I fit the reduced model for "mic" factor
effects, the extra degrees of freedom are being allocated to a nested
term rather than the residuals. The model has inc, mic and spp are
independent variables and vial nested within spp. inc and spp are
already coded as factors since they were entered as text in the
dataframe "t".

##Full Model
> fit<-lm(cmm~inc+factor(mic)+spp/factor(vial),t)
> anova(fit)
Analysis of Variance Table

Response: cmm
Df Sum Sq Mean Sq F value Pr(>F)
inc 1 2099.3 2099.3 387.6854 < 2.2e-16 ***
factor(mic) 2 502.3 251.2 46.3823 < 2.2e-16 ***
spp 2 7947.1 3973.5 733.8008 < 2.2e-16 ***
spp:factor(vial) 94 3746.9 39.9 7.3612 < 2.2e-16 ***
Residuals 1112 6021.5 5.4

## Reduced Model
> fitredmic<-lm(cmm~inc+spp/factor(vial),t)
> anova(fitredmic)
Analysis of Variance Table

Response: cmm
Df Sum Sq Mean Sq F value Pr(>F)
inc 1 2099.3 2099.3 387.6854 < 2.2e-16 ***
spp 2 8149.7 4074.9 752.5124 < 2.2e-16 ***
spp:factor(vial) 96 4046.6 42.2 7.7843 < 2.2e-16 ***
Residuals 1112 6021.5 5.4

##So the degrees of freedom for the comparison are 0:

> anova(fit,fitredmic)
Analysis of Variance Table

Model 1: cmm ~ inc + factor(mic) + spp/factor(vial)
Model 2: cmm ~ inc + spp/factor(vial)
Res.Df RSS Df Sum of Sq F Pr(>F)
1 1112 6021.5
2 1112 6021.5 0 -9.0949e-13

Is this meaningful? How can I fix this? Thank you!

Wes

```