[R] how to fit just a fixed effects model?

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Mon Sep 16 23:08:13 CEST 2002


"Pijus Virketis" <pvirketis at hbk.com> writes:

> Dear all,
> 
> How can one fit just a fixed effects model in R? lme() seems to
> require a random component, whereas I am just looking for something
> like STATA's "xtreg, fe" function.

Just lm() 

It *is* curious that you can't get lme() to come out with that special
case, though. You can, however, cheat it with code like

> z <- 1:nrow(Orthodont)
> fm2 <- lme(distance ~ age + Sex, data = Orthodont, random=~1|z)

This gives you


Random effects:
 Formula: ~1 | z
        (Intercept)  Residual
StdDev:    2.127071 0.7976516

although the terms are not really separately identifiable, only 
the residual error sqrt(2.127071^2+ 0.7976516^2)...

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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