Hi R-users I would like to extract the random effects ("1|SITE", "1+SPECIES|SITE" and "BA|SITE") from this model formula: Full_model <- formula (VAR ~ (1|SITE) + (1+SPECIES|SITE) + (BA|SITE) + HEIGHT + COND + NN_DIST) I tried: terms(Full_model) labels(terms(Full_model)) but I could not distinguish between random and fixed effects. thanks Lorenzo [[alternative HTML version deleted]]
Hi again, Sorry, probably I was not clear enough. I was wondering if there is a way in R to identify (and extract) only the random effects, which, because I am using the lmer function, are the terms with the symbol | on the left side of the grouping variable ("SITE" in my example). Thanks Lorenzo From: Lorenzo Cattarino Sent: Wednesday, 22 September 2010 5:23 PM To: r-help@r-project.org Subject: extracting random effects from model formula Hi R-users I would like to extract the random effects ("1|SITE", "1+SPECIES|SITE" and "BA|SITE") from this model formula: Full_model <- formula (VAR ~ (1|SITE) + (1+SPECIES|SITE) + (BA|SITE) + HEIGHT + COND + NN_DIST) I tried: terms(Full_model) labels(terms(Full_model)) but I could not distinguish between random and fixed effects. thanks Lorenzo [[alternative HTML version deleted]]
actually I need to extract the random effect from the formula, not the model any idea? ________________________________ From: Sacha Viquerat [mailto:sacha.vsop@googlemail.com] Sent: Wed 22/09/2010 5:55 PM To: Lorenzo Cattarino Subject: Re: [R] extracting random effects from model formula Am 22.09.2010 09:22, schrieb Lorenzo Cattarino:> Hi R-users > > > > I would like to extract the random effects ("1|SITE", "1+SPECIES|SITE" > and "BA|SITE") from this model formula: > > > > Full_model<- formula (VAR ~ (1|SITE) + (1+SPECIES|SITE) + (BA|SITE) + > HEIGHT + COND + NN_DIST) > > > > I tried: > > > > terms(Full_model) > > labels(terms(Full_model)) > > > > but I could not distinguish between random and fixed effects. > > > > thanks > > > > Lorenzo > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org 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. >try ranef(model). [[alternative HTML version deleted]]
On Sep 22, 2010, at 5:09 AM, Lorenzo Cattarino wrote:> actually I need to extract the random effect from the formula, not > the model > > any idea? > > ________________________________ > > From: Sacha Viquerat [mailto:sacha.vsop at googlemail.com] > Sent: Wed 22/09/2010 5:55 PM > To: Lorenzo Cattarino > Subject: Re: [R] extracting random effects from model formula > > > > Am 22.09.2010 09:22, schrieb Lorenzo Cattarino: >> Hi R-users >> >> >> >> I would like to extract the random effects ("1|SITE", "1+SPECIES| >> SITE" >> and "BA|SITE") from this model formula:> modterm <- attr(terms(Full_model), "term.labels") > modterm[grep("\\|", attr(terms(Full_model), "term.labels") )] [1] "1 | SITE" "1 + SPECIES | SITE" "BA | SITE">> >> >> >> Full_model<- formula (VAR ~ (1|SITE) + (1+SPECIES|SITE) + (BA|SITE) + >> HEIGHT + COND + NN_DIST) >> >> >> >> I tried: >> >> >> >> terms(Full_model) >> >> labels(terms(Full_model)) >> >> >> >> but I could not distinguish between random and fixed effects. >> >> >> >> thanks >> >> >> >> Lorenzo >> >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org 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. >> > > try ranef(model). > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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.David Winsemius, MD West Hartford, CT