[R] linear models

Douglas Bates bates at stat.wisc.edu
Fri Mar 31 18:05:00 CEST 2000


FAHEEM MITHA <faheem at email.unc.edu> writes:

> I have a couple of linear model related questions. 
> 
> 1) How do I produce a fixed effect linear model using lme? I saw somewhere
> (this may be Splus documentation since I use Splus and R interchangeably)
> that using lme(...,random= ~ -1 | groups,...) works, but it gives the same
> as lme(...,random= ~ 1 | groups,...), ie. fits a random effect intercept
> term.

I don't think you can fit a fixed-effects model with lme.

> The reason why I want to do this is test for the significance of the
> random effect intercept term. anova( , ) does not work for an lm model and
> lme model together.

You can do this if you list the lme model first in the call to
anova().

> 2) Is there some nice way of handling linear models which are of the form
> 
> response_ij = a_i + b_i x_ij + \epsilon_ij 
> 
> where a_i and b_i are fixed effects, x_ij is given (continuous) data,
> \epsilon_ij ~ N(0, \sigma^2), and the i's range over some group? This is
> basically a group of regression models, but I want them handled as one
> unit for the purposes of estimation of \sigma^2 etc. I know that lmList()
> does fit such a model, but does so as a group of separate models. I can
> see that this would be possible to do this using lm() and indicator
> variables, but this seems like a clumsy approach. Surely there is a better
> way.

If you look at the result of
 summary(fm)
where fm is a model fit by lmList you will see that the estimate of
\sigma^2 is the pooled estimate.  All the standard errors, etc. are
based on the pooled estimate of the variance.

Alternatively, the section on linear models in Venables and Ripley
(1999) shows how to use lm to fit separate models like this.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list