On Thu, Jul 5, 2012 at 11:40 AM, jacquesliu <jacques...@gmail.com> wrote: > I was asked to do a WLS estimation, so I thought of lm() with weights like > wls=lm(Y~X-1,weight=INC) > > however, it gives different result as below code, which use the formula of > WLS > y<-Y*INC^-0.5 > x<-X*INC^-0.5 > wls=lm(y~x-1) > > Can anybody explain to me why the first code can not give the right answer?
The two examples are using the opposite weights. To replicate the answer from the second approach with lm, use weight=INC^-1 In lm(), observations with high weights have more, um, weight. They influence the results more than observations with low weight. Your code does the opposite. -thomas -- Thomas Lumley Professor of Biostatistics University of Auckland ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.