Dear R users, I'm analyzing a particular score "y" among several individuals, each of which belongs to a center, a factor with three different levels (3 possible centers). I have treated the "center" as a fixed effect, and as a random term (package lme4): 1) model.fix <- glm(y ~ var.1 + var.2 + var.3 + var.4 + var.5 + center, family = "binomial", data = dat) 2) model.rand <- glmer(y ~ var.1 + var.2 + var.3 + var.4 + var.5 + (1 | center), family = "binomial", data = dat) The issue is that both models provide exactly the same coefficients and p-values for the 5 baseline variables, so I assumed that it was due to the small number of levels (in fact, too few ). However, when computing anova(model.rand, model.fix), the output indicates a p-value < 0.001 in favour of the "model.rand". What's happening? Should I take the random terms? Thanks for any help! Frank S. [[alternative HTML version deleted]]
Mitchell Maltenfort
2022-Jun-11 15:21 UTC
[R] Interpreting the result of a model with random effects
Looks like the center effect improves overall accuracy while being independent of the other terms. A few things to try Compare coef(model.fix) to fixef(model.rand). Add center as a fixed effect to model .fix Try a conditional logit (clogit from survival) See how consistent the coefficients are On Sat, Jun 11, 2022 at 11:14 AM Frank S. <f_j_rod at hotmail.com> wrote:> Dear R users, > > I'm analyzing a particular score "y" among several individuals, each of > which belongs to a center, a factor with three > different levels (3 possible centers). I have treated the "center" as a > fixed effect, and as a random term (package lme4): > > 1) model.fix <- glm(y ~ var.1 + var.2 + var.3 + var.4 + var.5 + center, > family = "binomial", data = dat) > 2) model.rand <- glmer(y ~ var.1 + var.2 + var.3 + var.4 + var.5 + (1 | > center), family = "binomial", data = dat) > > The issue is that both models provide exactly the same coefficients and > p-values for the 5 baseline variables, so I assumed > that it was due to the small number of levels (in fact, too few ). > However, when computing anova(model.rand, model.fix), > the output indicates a p-value < 0.001 in favour of the "model.rand". > What's happening? Should I take the random terms? > > Thanks for any help! > > Frank S. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. >-- Sent from Gmail Mobile [[alternative HTML version deleted]]
Bert Gunter
2022-Jun-11 16:57 UTC
[R] Interpreting the result of a model with random effects
Please note: I am not an expert. 1. If there are only 3 centers (you didn't say) , then they are not a random selection from a larger collection of centers and a random effects model is inappropriate anyway; 2. Otherwise, you want to estimate a centers variance component from a sample of size 3 ?? 3. You cannot -- or at least should not -- compare nested fixed effects models (with and without 'center') with different random effects structures. The number of df associated with random effects is unknown, and standard (asymptotic) likelihood ratio tests are wrong. There's a big literature on this. So my answer is no -- the anova p-value comparison is nonsense. Again, note my initial caveat -- perhaps it will serve as an invitation for an expert to respond. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sat, Jun 11, 2022 at 8:14 AM Frank S. <f_j_rod at hotmail.com> wrote:> > Dear R users, > > I'm analyzing a particular score "y" among several individuals, each of which belongs to a center, a factor with three > different levels (3 possible centers). I have treated the "center" as a fixed effect, and as a random term (package lme4): > > 1) model.fix <- glm(y ~ var.1 + var.2 + var.3 + var.4 + var.5 + center, family = "binomial", data = dat) > 2) model.rand <- glmer(y ~ var.1 + var.2 + var.3 + var.4 + var.5 + (1 | center), family = "binomial", data = dat) > > The issue is that both models provide exactly the same coefficients and p-values for the 5 baseline variables, so I assumed > that it was due to the small number of levels (in fact, too few ). However, when computing anova(model.rand, model.fix), > the output indicates a p-value < 0.001 in favour of the "model.rand". What's happening? Should I take the random terms? > > Thanks for any help! > > Frank S. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.