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. Thanks, Pijus ---- W: 212-588-7897 F: 212-446-1955 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
"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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Pijus, The gls function in the nlme library allows you to fit a linear model under certain error assumptions (eg some types of correlation), which might line up with those you'd use xtreg for in Stata. James. Pijus Virketis wrote:>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. > >Thanks, > >Pijus > > >---- >W: 212-588-7897 >F: 212-446-1955 > > >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- >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 >_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ > > >-- James McBroom Department of Statistics, web: http://www.stats.ox.ac.uk/~mcbroom University of Oxford, 1 South Parks Road, ph: +44 (0)1865 272879 Oxford OX1 3TG. fax: +44 (0)1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._