[R] Drop1 and weights

Yan Wong h.y.wong at leeds.ac.uk
Wed Mar 1 14:54:10 CET 2006


Hi,

If I used drop1 in a weighted lm fit, it seems to ignore the weights  
in the AIC calculation of the dropped terms, see the example below.  
Can this be right?

Yan

--------------------

library(car)
 > unweighted.model <- lm(trSex ~ (river+length +depth)^2- 
length:depth, dno2)
 > Anova(unweighted.model)
Anova Table (Type II tests)

Response: trSex
              Sum Sq  Df F value  Pr(>F)
river        0.1544   1  3.3151 0.07100 .
length       0.1087   1  2.3334 0.12911
depth        0.1917   1  4.1145 0.04461 *
river:length 0.0049   1  0.1049 0.74652
river:depth  0.3008   1  6.4567 0.01226 *
Residuals    5.9168 127
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 >
 > drop1(unweighted.model)
Single term deletions

Model:
trSex ~ (river + length + depth)^2 - length:depth
              Df Sum of Sq     RSS     AIC
<none>                       5.92 -401.97
river:length  1  0.004889    5.92 -403.86
river:depth   1      0.30    6.22 -397.37

### Both drop1 & Anova suggest dropping river:length
### Compare with the following:

 > weighted.model <- lm(trSex ~ (river+length +depth)^2-length:depth,  
dno2, weights=males+females)
 > Anova(weighted.model)
Anova Table (Type II tests)

Response: trSex
              Sum Sq  Df F value  Pr(>F)
river         1.471   1  3.3775 0.06843 .
length        1.002   1  2.2999 0.13187
depth         2.974   1  6.8295 0.01005 *
river:length  0.075   1  0.1733 0.67790
river:depth   2.020   1  4.6397 0.03313 *
Residuals    55.303 127
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 >
 > drop1(weighted.model)
Single term deletions

Model:
trSex ~ (river + length + depth)^2 - length:depth
              Df Sum of Sq     RSS     AIC
<none>                      55.30 -104.71
river:length  1    -49.33    5.97 -402.79
river:depth   1    -49.04    6.26 -396.39




More information about the R-help mailing list