An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20110318/739bdced/attachment.pl>
Linear mixed effect model
8 messages · Manuel Spínola, Ben Bolker
On 11-03-18 08:19 AM, Manuel Sp?nola wrote:
Dear list members, I am trying to fit a linear mixed model using the following variables:: Response variable: Swiftness.2 (This is the time it took for the otter to first approach the lure. The time ranges from 1 second (in which case the otter approached the lure almost immediately) to 600 seconds (10 minutes). Explanatory variables: 1) Subject (this is the individual otter -- each otter is measured for response to each lure, so it is a repeated measure on the individual); 2) sex; 3) facility size (small, med, large); 4) lure type (there were 6). I would like to see if the response variable is influenced by the explanatory variables including Subject like a "repeated measure" term (same animal expose to different lures). I am fitting the model: otter$Facility.Size = factor(otter$Facility.Size) otter$Sex = factor(otter$Sex) mod1 = lmer(Swiftness.1 ~ Lure + Sex + Facility.Size + (1|Subject), data = otter) summary(mod1)
> mod1 = lmer(Swiftness.1 ~ Lure + Sex + Facility.Size + (1|Subject),
data = otter)
> summary(mod1)
Linear mixed model fit by REML
Formula: Swiftness.1 ~ Lure + Sex + Facility.Size + (1 | Subject)
Data: otter
AIC BIC logLik deviance REMLdev
1277 1295 -631.3 1302 1263
Random effects:
Groups Name Variance Std.Dev.
Subject (Intercept) 0 0.00
Residual 21558 146.83
Number of obs: 102, groups: Subject, 17
Fixed effects:
Estimate Std. Error t value
(Intercept) 92.883 44.711 2.077
Lure -6.286 8.513 -0.738
Sex1 -3.266 29.199 -0.112
Facility.Size2 24.174 37.628 0.642
Facility.Size3 58.528 38.692 1.513
Correlation of Fixed Effects:
(Intr) Lure Sex1 Fcl.S2
Lure -0.666
Sex1 -0.327 0.000
Facilty.Sz2 -0.516 0.000 -0.055
Facilty.Sz3 -0.519 0.000 0.000 0.617
Is the model a plausible model and is it well parameterized?
Plausible, yes, except that you have apparently failed to transform Lure into a factor -- as it stands, lmer is treating it as a continuous covariate. Effects seem quite small. I would worry a little about your distribution, because I would guess that elapsed times are likely to be skewed. Have you looked at the residuals/thought about log-transforming? You are getting zero variance for the random effect (and a huge residual variance), which suggests a general lack of power. Ben Bolker
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20110318/13925f3c/attachment.pl>
1 day later
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20110319/4da9460e/attachment.pl>
On 11-03-19 10:47 AM, Manuel Sp?nola wrote:
Hi Ben and other list members, I looked at the residuals and log transforming the gave me heteroscedasticity, so I don't know if I need to transform. Is statistically appropriate to fit different models, lienear, gls, lme and compare them with AIC? mod1 = lm(Swiftness.1 ~ Lure + Sex + Facility.Size, data = otter) mod2 = gls(Swiftness.1 ~ Lure + Sex + Facility.Size, data = otter) mod3 = gls(Swiftness.1 ~ 1, data = otter) mod4 = lme(Swiftness.1 ~ Lure + Sex + Facility.Size, random = ~1|Subject, data = otter)
AICctab(mod1, mod2, mod3, mod4, weights = T, delta = TRUE, base = T,
sort = TRUE, nobs = 17)
AICc df dAICc weight
mod2 1276.4 10 0.0 1
mod4 1294.5 11 18.1 <0.001
mod3 1302.9 2 26.6 <0.001
mod1 1356.3 10 80.0 <0.001
A few thoughts: * you can in principle compare various models (including those with/without random effects), but it is a crude approximation for several reasons (boundary issues with random effects, marginal vs conditional AIC, etc. -- see <http://glmm.wikidot.com/faq> for more discussion). * Take a look at very recent discussions on this list about comparing lm vs gls vs lme; in particular make sure you have REML=TRUE/FALSE set appropriately. As you have done it, the fits may not be comparable. * I think you should retain the random effect of 'otter' in any case because it is a natural part of the experimental design (although I think that if you correctly set REML=FALSE you will get identical likelihoods between gls and lme, and gls will appear better because it is missing a random-effect variance parameter)
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20110319/580b3a09/attachment.pl>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 11-03-19 11:27 AM, Manuel Sp?nola wrote:
Thank you very much Ben, I decided to keep "otter" as a random factor: modA = lmer(Swiftness.1 ~ Lure + Sex + Facility.Size + (1|Subject), REML = F, data = otter) summary(modA) modB = lmer(Swiftness.1 ~ (1|Subject), REML = F, data = otter) summary(modB) modC = lmer(Swiftness.1 ~ Lure + (1|Subject), REML = F, data = otter) summary(modC)
AICctab(modA, modB, modC, weights = T, delta = TRUE, base = T, sort =
TRUE, nobs = 17)
AICc df dAICc weight
modB 1313.1 3 0.0 1
modC 1336.3 8 23.2 <0.001
modA 1374.5 11 61.4 <0.001
Output for best model:
summary(modB)
Linear mixed model fit by maximum likelihood
Formula: Swiftness.1 ~ (1 | Subject)
Data: otter
AIC BIC logLik deviance REMLdev
1311 1319 -652.6 1305 1298
Random effects:
Groups Name Variance Std.Dev.
Subject (Intercept) 0 0.00
Residual 21133 145.37
Number of obs: 102, groups: Subject, 17
Fixed effects:
Estimate Std. Error t value
(Intercept) 99.76 14.39 6.931
Is it fair to say that there is no effect of any of the factors?
Did you say that the variance 0 in the random effect output is low power?
Yes, although technically I would say that the factors are not useful for prediction; if you want to test for the presence of a significant effect, then fit the full model and report the p-values and confidence intervals from it. Yes, I would say that the zero variance represents noise/ low power: if you were to do the equivalent aov()-analysis it would probably report a negative variance (i.e., among-group mean square < within-group mean square). Ben -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk2E0bYACgkQc5UpGjwzenNYEgCfVyZWOsGQKku23cl9P2QYJE2P xf4AmQESmtzRM01AIdBJ38clLc9c2JXA =OGDG -----END PGP SIGNATURE-----
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20110319/edf7c629/attachment.pl>