0

I have two questions about running a glmm with a proportional response variable. I am using code modified from this question: Errors trying to run glmer with paired data and repeated measures (lme4)

First, my code (data is at the end):

    fit2 = glmmPQL(cbind(Ground, 1-Ground) ~ Treatment*Time,
                   random=~1|Site/Treatment, data=alitter[complete.cases(alitter$Ground),], # removes blanks
family=binomial(link = "logit"), correlation=corCAR1(form = ~Time|Site/Treatment))

Ground is a value ranging from 0 to 1 (including 0).

The code above gives the following error:

Error in Initialize.corCAR1(X[[i]], ...) : 
  covariate must have unique values within groups for "corCAR1" objects
In addition: Warning message:
In eval(family$initialize) : non-integer counts in a binomial glm!

Question 1: I am guessing the error is telling me my design is not balanced, which is correct - sampling difficulty meant some Time*Treatment combinations had to be abandoned. If this is correct, is there another way to account for when the repeated measures at a site are complete?

Question 2: I can't have straight proportions as the response variable. Hence

cbind(Ground, 1-Ground)

So, have I done that part correctly? For every proportion of ground cover, I have generated the remaining proportion, so every pair now adds to 1.

Data:

Site    Treatment   Time    Sample  Ground
Flynns  Treatment   Post    7   0
Flynns  Treatment   Post    6   0
Flynns  Treatment   Post    1   0
Flynns  Treatment   Post    2   0
Flynns  Treatment   Post    10  0
Flynns  Treatment   Pre 6   0
Flynns  Treatment   Pre 5   0
Peake   Treatment   Pre 1   0
Flynns  Control Pre 10  0
Homestead   Treatment   Post    3   0
Homestead   Control Post    5   0
Homestead   Control Post    8   0
Homestead   Control Post    6   0
Homestead   Control Post    7   0
Burgan  Treatment   Post    8   0.0075
Flynns  Treatment   Post    8   0.01
Burgan  Treatment   Post    4   0.015
Homestead   Treatment   Post    1   0.015
Homestead   Treatment   Post    10  0.015
Flynns  Treatment   Post    5   0.02
Burgan  Treatment   Post    3   0.02
Homestead   Treatment   Post    6   0.02
Burgan  Treatment   Post    2   0.025
Grants tk   Treatment   Post    2   0.03
Flynns  Treatment   Post    4   0.03
Homestead   Treatment   Post    2   0.03
Flynns  Treatment   Post    9   0.04
Flynns  Treatment   Post    3   0.04
Peake   Treatment   Post    6   0.04
Homestead   Treatment   Post    4   0.04
Homestead   Treatment   Post    9   0.045
Flynns  Treatment   Pre 7   0.05
Flynns  Treatment   Pre 9   0.05
Flynns  Control Pre 1   0.05
Flynns  Treatment   Pre 10  0.05
Flynns  Treatment   Pre 8   0.05
Flynns  Control Pre 2   0.05
Flynns  Control Pre 7   0.05
Grants tk   Treatment   Pre 10  0.05
Burgan  Treatment   Pre 5   0.05
Flynns  Control Pre 5   0.05
Grants tk   Control Pre 2   0.05
Peake   Treatment   Pre 5   0.05
Burgan  Treatment   Pre 2   0.05
Burgan  Treatment   Pre 4   0.05
Burgan  Treatment   Pre 1   0.05
Grants tk   Control Pre 9   0.05
Grants tk   Treatment   Pre 9   0.05
Homestead   Control Post    4   0.05
Homestead   Treatment   Pre 6   0.05
Peake   Treatment   Pre 8   0.05
Peake   Treatment   Pre 4   0.05
Homestead   Control Post    3   0.05
Homestead   Treatment   Pre 3   0.05
Peake   Treatment   Post    5   0.05
Peake   Treatment   Pre 10  0.05
Homestead   Control Post    2   0.05
Peake   Control Post    2   0.05
Homestead   Control Post    10  0.05
Peake   Control Post    3   0.05
Burgan  Treatment   Post    7   0.0525
Grants tk   Treatment   Post    6   0.06
Burgan  Treatment   Post    5   0.075
Peake   Treatment   Post    1   0.0825
Homestead   Treatment   Post    8   0.09
Flynns  Treatment   Pre 3   0.1
Burgan  Treatment   Pre 10  0.1
Grants tk   Control Post    3   0.1
Flynns  Treatment   Pre 4   0.1
Homestead   Treatment   Pre 7   0.1
Flynns  Control Pre 6   0.1
Peake   Control Post    5   0.1
Grants tk   Control Post    2   0.1
Burgan  Treatment   Pre 6   0.1
Peake   Control Post    6   0.1
Grants tk   Control Post    10  0.1
Peake   Control Pre 3   0.1
Grants tk   Control Post    7   0.1
Flynns  Control Pre 3   0.1
Peake   Treatment   Post    8   0.1
Peake   Control Pre 2   0.1
Grants tk   Treatment   Pre 4   0.1
Homestead   Treatment   Pre 9   0.1
Grants tk   Treatment   Pre 8   0.1
Peake   Control Pre 9   0.1
Grants tk   Treatment   Post    9   0.1
Homestead   Treatment   Pre 4   0.1
Flynns  Control Pre 8   0.1
Peake   Control Post    7   0.1
Grants tk   Control Post    9   0.1
Burgan  Treatment   Pre 3   0.1
Grants tk   Treatment   Pre 5   0.1
Peake   Control Post    10  0.1
Peake   Control Pre 6   0.1
Peake   Treatment   Pre 7   0.1
Peake   Treatment   Pre 9   0.1
Peake   Control Pre 7   0.1
Grants tk   Control Pre 4   0.1
Burgan  Treatment   Pre 8   0.1
Grants tk   Treatment   Post    8   0.1
Homestead   Treatment   Pre 2   0.1
Peake   Treatment   Pre 6   0.1
Peake   Control Pre 8   0.1
Peake   Control Post    4   0.1
Homestead   Control Post    1   0.1
Burgan  Control Post    3   0.1
Homestead   Control Post    9   0.1
Homestead   Treatment   Post    5   0.11
Grants tk   Treatment   Post    10  0.12
Grants tk   Treatment   Post    7   0.12
Burgan  Treatment   Post    6   0.12
Burgan  Treatment   Post    1   0.135
Burgan  Treatment   Post    9   0.14
Burgan  Treatment   Post    10  0.1425
Flynns  Treatment   Pre 2   0.15
Flynns  Treatment   Pre 1   0.15
Burgan  Treatment   Pre 9   0.15
Grants tk   Control Post    1   0.15
Grants tk   Treatment   Pre 2   0.15
Grants tk   Treatment   Post    4   0.15
Grants tk   Control Pre 3   0.15
Flynns  Control Pre 4   0.15
Grants tk   Control Post    4   0.15
Grants tk   Treatment   Pre 7   0.15
Grants tk   Control Pre 6   0.15
Burgan  Treatment   Pre 7   0.15
Homestead   Treatment   Pre 1   0.15
Homestead   Treatment   Pre 10  0.15
Flynns  Control Pre 9   0.15
Grants tk   Control Pre 7   0.15
Grants tk   Control Pre 5   0.15
Grants tk   Treatment   Pre 3   0.15
Grants tk   Control Pre 10  0.15
Peake   Control Post    9   0.15
Peake   Treatment   Pre 3   0.15
Grants tk   Treatment   Pre 6   0.15
Homestead   Treatment   Pre 5   0.15
Homestead   Treatment   Pre 8   0.15
Peake   Control Post    8   0.15
Burgan  Control Post    10  0.15
Burgan  Control Post    7   0.15
Peake   Control Pre 10  0.15
Peake   Treatment   Post    7   0.15
Peake   Treatment   Post    10  0.15
Grants tk   Treatment   Post    5   0.1575
Peake   Treatment   Post    4   0.1625
Grants tk   Control Post    6   0.2
Peake   Control Post    1   0.2
Peake   Treatment   Post    2   0.2
Grants tk   Treatment   Post    3   0.2
Grants tk   Control Pre 1   0.2
Grants tk   Treatment   Pre 1   0.2
Peake   Control Pre 5   0.2
Peake   Control Pre 4   0.2
Burgan  Control Post    9   0.2
Homestead   Treatment   Post    7   0.2
Burgan  Control Post    8   0.2
Peake   Treatment   Post    9   0.2
Burgan  Control Post    6   0.2
Peake   Treatment   Post    3   0.225
Peake   Control Pre 1   0.25
Burgan  Control Post    5   0.25
Peake   Treatment   Pre 2   0.25
Grants tk   Control Pre 8   0.25
Burgan  Control Post    2   0.25
Grants tk   Treatment   Post    1   0.315
Grants tk   Control Post    8   0.35
Burgan  Control Post    1   0.35
Grants tk   Control Post    5   0.4
Burgan  Control Post    4   0.4
Flynns  Control Post    2   
Flynns  Control Post    3   
Flynns  Control Post    6   
Homestead   Control Pre 10  
Flynns  Control Post    5   
Flynns  Control Post    10  
Flynns  Control Post    7   
Homestead   Control Pre 9   
Homestead   Control Pre 7   
Flynns  Control Post    8   
Flynns  Control Post    1   
Flynns  Control Post    4   
Flynns  Control Post    9   
Homestead   Control Pre 1   
Homestead   Control Pre 6   
Homestead   Control Pre 5   
Homestead   Control Pre 3   
Homestead   Control Pre 8   
Homestead   Control Pre 4   
Homestead   Control Pre 2   
Grubbmeister
  • 857
  • 8
  • 25
  • Two comments: (1) Why do you put a nested random effect for `Treament`? I'd first start with the random effects for `Site`. (2) Given that `Ground` is in [0, 1], you could consider fitting a Beta mixed effects model. For example, you can do that in the [**GLMMadaptive**](https://drizopoulos.github.io/GLMMadaptive/) package; for more info check: https://drizopoulos.github.io/GLMMadaptive/articles/Custom_Models.html#beta-mixed-effects-model – Dimitris Rizopoulos Sep 26 '18 at 07:58
  • Thanks. 1) I think it's because there is a treatment and control plot at each site; so treatment is nested within site. 2) I spent a lot of time trying Beta mixed models with zero success. I kept getting p-values of 1 for everything. This worked, however – Grubbmeister Sep 26 '18 at 08:18
  • OK, but it doesn't necessarily mean that the nested random effect is supported by the data. A similar example in my world (Biostatistics) is multi-center clinical trials. Patients in each hospital (your `Site`) receive both treatments. However, often you only put a random effect on the hospital level. Regarding (2), have you also tried GLMMadaptive and it doesn't work? – Dimitris Rizopoulos Sep 26 '18 at 08:26
  • Ok, makes sense. I wasn't convinced about its necessity, but it is how the study was structured. I tried GLMMadaptive using: gm <- mixed_model(Ground ~ Treatment*Time, random = ~1 |Site, data = alitter[complete.cases(alitter$Ground),], family = beta.fam(), n_phis = 1) but get the following error: Error in optim(par = b_i, fn = log_post_b, gr = score_log_post_b, method = "BFGS", : initial value in 'vmmin' is not finite – Grubbmeister Sep 26 '18 at 08:48
  • Have you transformed `Ground` like this: `alitter$Ground2 <- (alitter$Ground * (nrow(alitter) - 1) + 0.5) / nrow(alitter)` and use then `Ground2` as a response variable? – Dimitris Rizopoulos Sep 26 '18 at 08:51
  • Did that and the model now runs. The output, however, suggests everything is highly significant - that is clearly not the case from the boxplots I have. – Grubbmeister Sep 26 '18 at 09:02
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/180826/discussion-between-dimitris-rizopoulos-and-grubbmeister). – Dimitris Rizopoulos Sep 26 '18 at 18:35

0 Answers0