[R] lm with data=(means,sds,ns)

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Sun Apr 18 03:27:50 CEST 2004


Hi Folks,

I am dealing with data which have been presented as

  at each x_i, mean m_i of the y-values at x_i,
               sd s_i of the y-values at x_i
               number n_i of the y-values at x_i

and I want to linearly regress y on x.

There does not seem to be an option to 'lm' which can
deal with such data directly, though the regression
problem could be algebraically expressed in these terms.

One way of fudging it would be to replace each m_i by
a set  of n_i numbers Y_i constructed as

  u_i <- rnorm(ni)

  Y_i <- m_i + s_i*(u_i - mean(u_i))/sd(u_i)

and associate these with X_i <- rep(x_i,n_i), thereby
constructing a regression-equivalent set of pseudo "raw data"
which could be fed to lm(Y~X). However, this strikes me as
cumbersome, at least, and even ugly!

Is there a direct way to go from {(n_i,m_i,s_i)} to the
fitted regression, with summaries and all (and use of 'predict')?

With thanks,
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 167 1972
Date: 18-Apr-04                                       Time: 02:27:50
------------------------------ XFMail ------------------------------




More information about the R-help mailing list