[R] inconsistent behaviour of add1 and drop1 with a weighted linear model

Peter Dalgaard p.dalgaard at biostat.ku.dk
Tue Mar 13 17:35:07 CET 2007


Jenny Hodgson wrote:
> Dear R Help,
> I have noticed some inconsistent behaviour of add1 and drop1 with a 
> weighted linear model, which affects the interpretation of the results.
> I have these data to fit with a linear model, I want to weight them by 
> the relative size of the geographical areas they represent.
> _________________________________________________________________________________________
>  > example
>            y        x1       x2   weights
> 1  -4.546477 0.1859556 50.00000 0.9466022
> 2   1.484246 0.4740497 29.88000 1.3252430
> 3   2.203681 0.8594264 16.93333 0.9466022
> 4   1.943163 0.8713360 42.11765 2.7766997
> 5   1.886473 0.9006082 19.00000 0.9466022
> 6   1.795393 0.8455183 23.68421 1.1674760
> 7   1.878077 0.5641396 35.00000 0.8203885
> 8  -4.215484 0.4356858 58.75000 0.4417477
> 9   1.993339 0.5440061 19.28571 0.8519420
> 10  1.560869 0.6285066 19.54545 0.8203885
> 11  2.761535 0.7017720 15.83333 0.1262136
> 12  0.995959 0.4638751  0.00000 0.9466022
> 13 -4.516514 0.2794199 77.85714 0.8834954
>  > sum(example$weights)
> [1] 13.00000
>
>  > model<-lm(y~1,data=example,weights=weights)
>  > add1(model,.~.+x1+x2)
> Single term additions
>
> Model:
> y ~ 1
>        Df Sum of Sq    RSS    AIC
> <none>              94.000 27.719
> x1      1    55.290 38.710 18.185
> x2      1    58.630 35.371 17.012
>   
Which version of R??!

I get (2.4.1 on Fedora 6):

 > add1(model,.~.+x1+x2)
Single term additions

Model:
y ~ 1
       Df Sum of Sq    RSS    AIC
<none>              74.541 24.703
x1      1    44.377 30.164 14.942
x2      1    36.619 37.922 17.918



More information about the R-help mailing list