I designed an experiment to observe the shading effect in the distribution of 2 species of crabs through time. So basically I have 4 levels of shading (no shade, 20%, 50%, and 80%) with 7 ID to each (28 in total), and counted the number of species A and B in different time points (0, 1, 2, 3, 5, 7, 10, and 13 months). Therefore I compared a random intercept model with a random slope model and the code and summary are as follows:
a <- cbind(ul=Eco$ul, uu=Eco$total - Eco$ul)
kable(a[1:224,])
modr1 <- glmer(a ~ time + shade + time:shade + (time|id), data=Eco, family = "binomial" (link="logit"), control = glmerControl(optimizer ="Nelder_Mead"))
modr2 <- glmer(a ~ time + shade + time:shade + (1|id), data=Eco, family = "binomial"(link="logit"), control = glmerControl(optimizer ="Nelder_Mead"))
anova(modr2, modr1, test="Chisq")
modr2: a ~ time + shade + time:shade + (1 | id)
modr1: a ~ time + shade + time:shade + (time | id)
npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
modr2 9 1459.5 1489.9 -720.75 1441.5
modr1 11 1449.5 1486.7 -713.73 1427.5 14.04 2 0.0008938 ***
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
summary(modr1)
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod]
Family: binomial ( logit )
Formula: a ~ time + shade + time:shade + (time | id)
Data: Eco
Control: glmerControl(optimizer = "Nelder_Mead")
AIC BIC logLik deviance df.resid
1449.5 1486.6 -713.7 1427.5 206
Scaled residuals:
Min 1Q Median 3Q Max
-4.7771 -1.1861 0.0898 0.9981 6.6329
Random effects:
Groups Name Variance Std.Dev. Corr
id (Intercept) 0.464780 0.68175
time 0.002967 0.05447 0.18
Number of obs: 217, groups: id, 28
Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 2.403518 0.311480 7.716 1.2e-14 ***
time -0.058801 0.032595 -1.804 0.0712 .
shade20 -0.806281 0.420579 -1.917 0.0552 .
shade50 -0.336302 0.425565 -0.790 0.4294
shade80 -1.132901 0.417071 -2.716 0.0066 **
time:shade20 0.009717 0.041886 0.232 0.8165
time:shade50 -0.028839 0.043842 -0.658 0.5107
time:shade80 -0.096730 0.042004 -2.303 0.0213 *
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) time shad20 shad50 shad80 tm:s20 tm:s50
time -0.233
shade20 -0.732 0.163
shade50 -0.724 0.160 0.532
shade80 -0.744 0.172 0.546 0.539
time:shad20 0.170 -0.762 -0.160 -0.120 -0.126
time:shad50 0.159 -0.719 -0.114 -0.183 -0.116 0.556
time:shad80 0.179 -0.776 -0.126 -0.123 -0.155 0.592 0.554
My questions are: How to interpret the random effect?? How can I know the percentage of explanation from both random and fixed factors?? Do I need to know the variance of the residuals?
Thanks!