LMM without Random effect: I want to run an LMM both with and without the random factor (ID). And then extract the log-lik values from the two models in order to generate a p-value. with random factor as: lmer(y~x+(1|ID),data) Question: can I simply substitute a dummy var (e.g. populated by zeros) for "ID" to run the model without the random factor? when I try this R returns values that seem reasonable, but I want to be sure this is appropriate.>From other inquires in the forum it seems that substituting ("ID-1") or somevariant like that, does not work. Thanks for your thoughts. Baugh -- View this message in context: http://r.789695.n4.nabble.com/lmm-WITHOUT-random-factor-lme4-tp3384054p3384054.html Sent from the R help mailing list archive at Nabble.com.
On Mar 17, 2011; 11:43am Baugh wrote:>> Question: can I simply substitute a dummy var (e.g. populated by zeros) >> for "ID" to run the model >> without the random factor? when I try this R returns values that seem >> reasonable, but I want to be sure >> this is appropriate.If you can fit the model using lme (and it looks like you easily can) then another check would be: ## Compare models with and without random effects fm <- lm(Reaction ~ Days, sleepstudy) fm1 <- lme(Reaction ~ Days, random= ~1|Subject, sleepstudy) anova(fm1, fm) ## lme-fitted model must come first Regards, Mark. -- View this message in context: http://r.789695.n4.nabble.com/lmm-WITHOUT-random-factor-lme4-tp3384054p3384072.html Sent from the R help mailing list archive at Nabble.com.
Dear Mark, You cannot compare lm() with lme() because the likelihoods are not the same. Use gls() instead of lm() library(nlme) data("sleepstudy", package = "lme4") fm <- lm(Reaction ~ Days, sleepstudy) fm0 <- gls(Reaction ~ Days, sleepstudy) logLik(fm) logLik(fm0) fm1 <- lme(Reaction ~ Days, random= ~1|Subject, sleepstudy) anova(fm0, fm1) Best regards, Thierry ---------------------------------------------------------------------------- ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie & Kwaliteitszorg Gaverstraat 4 9500 Geraardsbergen Belgium Research Institute for Nature and Forest team Biometrics & Quality Assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 Thierry.Onkelinx at inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey> -----Oorspronkelijk bericht----- > Van: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] Namens Mark Difford > Verzonden: donderdag 17 maart 2011 10:55 > Aan: r-help at r-project.org > Onderwerp: Re: [R] lmm WITHOUT random factor (lme4) > > On Mar 17, 2011; 11:43am Baugh wrote: > > >> Question: can I simply substitute a dummy var (e.g. populated by > >> zeros) for "ID" to run the model without the random factor? when I > >> try this R returns values that seem reasonable, but I want > to be sure > >> this is appropriate. > > If you can fit the model using lme (and it looks like you > easily can) then another check would be: > > ## Compare models with and without random effects fm <- > lm(Reaction ~ Days, sleepstudy) > fm1 <- lme(Reaction ~ Days, random= ~1|Subject, sleepstudy) > anova(fm1, fm) ## lme-fitted model must come first > > Regards, Mark. > > -- > View this message in context: > http://r.789695.n4.nabble.com/lmm-WITHOUT-random-factor-lme4-t > p3384054p3384072.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >
On Mar 17, 2011; 04:29pm Thierry Onkelinx wrote:>> You cannot compare lm() with lme() because the likelihoods are not the >> same. Use gls() instead of lm()Hi Thierry, Of course, I stand subject to correction, but unless something dramatic has changed, you can. gls() can be used if you need to accommodate a correlation structure. The method I have outlined, i.e. anova(lme$obj, lm$obj), is detailed in Pinheiro & Bates (2000) beginning page 154. Please refer to this if you doubt me. Regards, Mark. -- View this message in context: http://r.789695.n4.nabble.com/lmm-WITHOUT-random-factor-lme4-tp3384054p3384802.html Sent from the R help mailing list archive at Nabble.com.
On Mar 17, 2011; 04:29pm Thierry Onkelinx wrote:>> You cannot compare lm() with lme() because the likelihoods are not the >> same. Use gls() instead of lm()And perhaps I should have added the following: First para on page 155 of Pinheiro & Bates (2000) states, "The anova method can be used to compare lme and lm objects." Regards, Mark. -- View this message in context: http://r.789695.n4.nabble.com/lmm-WITHOUT-random-factor-lme4-tp3384054p3384823.html Sent from the R help mailing list archive at Nabble.com.