# Generalized Linear Mixed Model in R with repeated measures

I am trying to investigate how four variables (var1=continuous, var2=factor, var3=factor, var4=continuous) influence the number of trials individuals approached (out of total nr of trials --> binomial) across two conditions that differed in food availability (food availability 1 = 42 trials; food availability 8 = 35 trials) (n = 19 individuals). The response variable is binomial as it is the number of trials out of total number of trials. I am using the 'lmer' function of the lme4 package.

I thought the additive model I should run would be with random factor ID:

glmer(cbind(appr_Y,appr_N) ~ Condition+Var1+Var2+Var3+Var4+(1|ID), data=dataset,
family=binomial)


However, the result I get shows that Condition is super significant (p < 2e-16) while the other variables aren't, while exploring the data visually shows no difference in the response variable for Condition and the variables having strong effects.

Below a dummy representing the large data table:

Con ID  Var1  Var2  appr_Y  appr_N  Trial_total
1   1   10      y   14      6       20
1   2   4       y   10      10      20
1   3   5       n   5       15      20
1   4   32      n   18      2       20
1   5   11      y   3       17      20
2   1   10      y   20      5       25
2   2   4       y   10      15      25
2   3   5       n   24      1       25
2   4   32      n   11      14      25
2   5   11      y   7       18      25


What am I doing wrong?

update: I analysed the data with GenStat (which doesn't show AIC values) and the output is totally different. In GenStat it asks for the random factor (here ID) and the denominator (here Trial_total), which is different than putting in Appr_Y, Appr_N.

update2: The above dataset was just a dummy. I hereby provide the 'summary' of the model and the information about the dataset:

> summary(GLMM1)
Generalized linear mixed model fit by the Laplace approximation
Formula: cbind(Appr_Y, Appr_N) ~ Condition + Var1 + Var2 + Var3 + Var4 + (1 | ID)
Data: dataset
AIC   BIC logLik deviance
102.1 113.5 -44.04    88.08
Random effects:
Groups Name        Variance Std.Dev.
ID     (Intercept) 0.59495  0.77133
Number of obs: 38, groups: ID, 19

Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept)       -2.43536    0.60237  -4.043 5.28e-05 ***
Condition8         1.14942    0.12274   9.365  < 2e-16 ***
Var1               0.04524    0.04002   1.130   0.2583
Var2Paired        -0.35299    0.47970  -0.736   0.4618
Var3no             0.55914    0.44095   1.268   0.2048
Var4               0.11996    0.06282   1.909   0.0562 .
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
(Intr) Cndt8- Var1 Var2P Var3no
Cndtn8-strn -0.128
Var1        -0.294  0.015
Var2unp     -0.474 -0.015 -0.352
Var3no      -0.178  0.016 -0.310 -0.097
Var4        -0.664  0.021 -0.078  0.467 -0.134
> str(dataset)
'data.frame':   38 obs. of  9 variables:
$ID : Factor w/ 19 levels "39","40","41",..: 1 2 3 4 5 6 7 8 9 10 ...$ Appr_Y      : num  3 12 0 7 27 6 12 1 5 17 ...
$Appr_N : num 39 30 42 35 15 36 30 41 37 25 ...$ Var2        : Factor w/ 2 levels "paired","unpaired": 2 2 2 2 1 1 2 1 2 1 ...
$Var1 : num 2 16 19 18 13 11 14 1 8 9 ...$ Var3        : Factor w/ 2 levels "yes","no": 2 2 2 1 2 2 2 1 1 2 ...
$Var4 : num 2.6 6.87 2.4 1.1 4.32 ...$ Condition   : Factor w/ 2 levels "1","8": 1 1 1 1 1 1 1 1 1 1 ...
\$ n           : num  42 42 42 42 42 42 42 42 42 42 ...


Do I perhaps have to do something with weighing the data as trial nr is not the same across conditions? Or using Appr_Y, total nr of trials instead of Appr_Y, Appr_N ?

• Welcome to the site, Jolle. – StasK Jan 28 '13 at 14:25
• Welcome to this site, Jolle. There's no need to post the same question twice. – chl Jan 28 '13 at 15:19