[R] Weighted regresion using lm

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Thu Oct 28 21:39:06 CEST 2004



Yu Shao wrote:

> Hi:
> 
> Could anyone help me to clarify this: are the weights normalized inside lm 
> function (package:stats) before applied to the error term?  For example:
> 
> 
>>lm (cost ~ material, weights=quatity, data=receipt)
> 
> 
> will lm normalize quatity such that sum(quatity) = 1? I traced to lm.wfit and 
> then the weights get transferred into a precompiled FORTRAN module so I can't 
> figure out. Thanks!
> 


Did you look at ?lm.wfit?

        w: vector of weights (length 'n') to be used in the fitting
           process for the 'wfit' functions.  Weighted least squares is
           used with weights 'w', i.e., 'sum(w * e^2)' is minimized.

So, no, the weights are not normalized.

--sundar

> 
> 
> 
>>version
> 
>          _                   
> platform sparc-sun-solaris2.9
> arch     sparc               
> os       solaris2.9          
> system   sparc, solaris2.9   
> status                       
> major    1                   
> minor    9.0                 
> year     2004                
> month    04                  
> day      12                  
> language R                
> 
> 
> Yu Shao
> Wadsworth Center
> NY Department of Health
> Albany, NY 12208
> 
> ______________________________________________
> 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




More information about the R-help mailing list