# [R] Drop1 and weights

Yan Wong h.y.wong at leeds.ac.uk
Wed Mar 8 12:31:21 CET 2006

```On 2 Mar 2006, at 17:56, Prof Brian Ripley wrote:

> On Thu, 2 Mar 2006, Yan Wong wrote:
>
>>
>> Indeed, I realised this, but assumed that the problem could be
>> understood even without my dataset. I'll test my data on the patched
>> version when it becomes available, and re-post then.

I've just tried R-patched, and it now works as expected. Thanks for
the quick fix. As you point out, the glm and lm versions differ in
AIC reported, but only by an additive constant, and so the tests are
not affected.

Yan

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

> weighted.lm <- lm(trSex ~ (river+length +depth)^2-length:depth,
dno2, weights=males+females)
> d1.lm <- drop1(weighted.lm, test="F");
> weighted.glm <- glm(trSex ~ (river+length +depth)^2-length:depth,
dno2, weights=males+females, family="gaussian")
> d1.glm <- drop1(weighted.glm, test="F");
>
> #differ by a constant
> d1.lm\$AIC - d1.glm\$AIC
[1] 628.1381 628.1381 628.1381
>
> Anova(weighted.lm)
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
> d1.lm
Single term deletions

Model:
trSex ~ (river + length + depth)^2 - length:depth
Df Sum of Sq      RSS      AIC F value   Pr(F)
<none>                      55.303 -104.710
river:length  1     0.075   55.379 -106.529  0.1733 0.67790
river:depth   1     2.020   57.324 -101.938  4.6397 0.03313 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> d1.glm
Single term deletions

Model:
trSex ~ (river + length + depth)^2 - length:depth
Df Deviance     AIC F value   Pr(F)
<none>             55.30 -732.85
river:length  1    55.38 -734.67  0.1733 0.67790
river:depth   1    57.32 -730.08  4.6397 0.03313 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

```