1
$\begingroup$

I am having a little bit of trouble wrapping my head around how to specify my glmer model. My design is as follows:

  • y is a binomial (Bernoulli) response variable
  • x1 is a categorical (factor) predictor variable with 3 levels (repeated measures)
  • x2 is a categorical (factor) predictor variable with 2 levels (independent measures)

In this experiment, each subject is exposed to every level of x1, completing 4 trials for each level (12 trials total). The order of each level is counterbalanced. For example, if A,B,C are the three levels of x1, one participant may complete 12 trials in the following order: A,A,A,A,C,C,C,C,B,B,B,B, or C,C,C,C,B,B,B,B,A,A,A,A, and so forth. Additionally, each subject is randomly assigned to a level of x2, making this an independent measures predictor variable.

We are looking to search for main effects and interactions between x1 and x2, but we need to properly specify the generalized linear mixed effect model. We have tried many approaches, but do not know which is correct. Since each subject contributes 12 responses overall in the data, we need a way to account for the fact that those 12 responses are not independent. I am thinking of treating trial as the slope of the random effect (subject) to account for that. Is this the correct approach or am I on the wrong track?

These are some that I have played with

m1 <- glmer(y ~ x1 * x2 + (1+trial|subject), family = binomial)
m2 <- glmer(y ~ x1 * x2 + (1|subject), family = binomial)

To look at just the effect of x2 I tried this:

m3 <- glmer(y ~ x2 + (1+trial|subject), family = binomial)
$\endgroup$
2
  • $\begingroup$ What exactly is a "trial" here ? It sounds like you are calling each observation a trial - is that right ? If so then it doesn't make sense for trial to be a random effect $\endgroup$ Commented Jan 13, 2021 at 20:07
  • $\begingroup$ A trial is each observation, yes. The reason we decided trial to be a random effect is because there might be learning effects over the course of the experiment. $\endgroup$
    – darrenmk
    Commented Jan 14, 2021 at 21:05

1 Answer 1

1
$\begingroup$

The heart of this question seems to be how to treat the trial variable.

It is clear that random intercepts are needed for subject to account for the repeated measures.

By specifying trial as a random slope for subjects we are allowing the "effect" of trial to vary for each subject. Since trial is absent as a fixed effect in your models, this means that the overall "effect" of trial is zero, but each subject will have their own slope. This is rarely warranted - it is more usual to include the random slopes variable as a fixed effect too, so that the overall "effect" is not zero. However if you have good reason to believe that the overall "effect" of trial is indeed zero, then that would be OK.

From the description, it seems that x1 and x2 are not associated with each other. Therefore, it doesn't make much sense to exclude x1 in the last model. Assuming that both are associated with the outcome, then x1 will be a competing exposure and should result in a more precise estimate for x2 when included (ie smaller standard error) and vice versa.

$\endgroup$
1
  • $\begingroup$ Thank you! This is great :) $\endgroup$
    – darrenmk
    Commented Jan 17, 2021 at 0:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.