It looks like at some point weighted.residuals() was changed, and broke
this. The models are fitted correctly, but AIC is wrong. However, note
that it does work correctly for a glm() fit which gives you a workaround.
You example is not reproducible, so I was unable to test the workaround
nor the correction which will short;y be in R-patched.
On Wed, 1 Mar 2006, Yan Wong wrote:
> 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
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595