Skip to content
Prev 33280 / 398506 Next

help with weights in lm and glm

On Sun, 27 Jan 2002, Roseli A. Leandro wrote:

            
Because it's looking in the environment of the model formula.

That's why it can find the other variables in the model even though you
didn't specify a dataframe to search.

You can use

function(model){
  www<-fitted(model)
  update(model, weights=www)
}

which does work (although it arguably shouldn't).

The handling of weights= in these modelling functions is a horrible wart
on the language.  Although they look like ordinary arguments they have
very strange scoping rules.


	-thomas