Dear Adai,

> -----Original Message-----
> From: Adaikalavan Ramasamy [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, May 08, 2007 8:38 PM
> To: S Ellison
> Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [email protected]
> Subject: Re: [R] Weighted least squares
> 
> http://en.wikipedia.org/wiki/Weighted_least_squares gives a 
> formulaic description of what you have said.
> 
> I believe the original poster has converted something like this
> 
>       y         x
>       0       1.1
>       0       2.2
>       0       2.2
>       0       2.2
>       1       3.3
>       1       3.3
>       2       4.4
>          ...
> 
> into something like the following
> 
>       y         x     freq
>       0       1.1        1
>       0       2.2        3
>       1       3.3        2
>       2       4.4        1
>          ...
> 
> Now, the variance of means of each row in table above is ZERO 
> because the individual elements that comprise each row are 
> identical. Therefore your method of using inverse-variance 
> will not work here.
> 
> Then is it valid then to use lm( y ~ x, weights=freq ) ?

No, because the weights argument gives inverse-variance weights not case
weights.

Regards,
 John

> 
> Regards, Adai
> 
> 
> 
> S Ellison wrote:
> > Hadley,
> > 
> > You asked
> >> .. what is the usual way to do a linear regression when you have 
> >> aggregated data?
> > 
> > Least squares generally uses inverse variance weighting. 
> For aggregated data fitted as mean values, you just need the 
> variances for the _means_. 
> > 
> > So if you have individual means x_i and sd's s_i that arise 
> from aggregated data with n_i observations in group i, the 
> natural weighting is by inverse squared standard error of the 
> mean. The appropriate weight for x_i would then be 
> n_i/(s_i^2). In R, that's n/(s^2), as n and s would be 
> vectors with the same length as x. If all the groups had the 
> same variance, or nearly so, s is a scalar; if they have the 
> same number of observations, n is a scalar. 
> > 
> > Of course, if they have the same variance and same number 
> of observations, they all have the same weight and you 
> needn't weight them at all: see previous posting!
> > 
> > Steve E
> > 
> > 
> > 
> > *******************************************************************
> > This email and any attachments are confidential. Any use, 
> > co...{{dropped}}
> > 
> > ______________________________________________
> > [email protected] 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.
> > 
> > 
> > 
> 
>

______________________________________________
[email protected] 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.

Reply via email to