# Longitudinal mixed-effect model with crossed random effects

I'm having a hard time figuring out the appropriate fixed and random effect structure for my model and would appreciate some help. In my study the frequency of two environmental behaviors was assessed across three time points. Participants intended to increase one of those behaviors while they didn't intend to change the other one. In addition self-control was assessed. An example data set for one participant looks this:

ID Intention time environmental behavior self-control
1 1 t1 2 4
1 1 t2 3 4
1 1 t3 4 4
1 0 t1 4 4
1 0 t2 4 4
1 0 t3 3 4

So, I have six rows for each participant, all participants are in both the intention and no-intention group, which makes it a within (or crossed) design.

• time points are treated categorically (altough I consider changing that as not everyone responded at the same time)
• the frequency of environmental behavior and self-control were assessed on Likert scales (1 - 5), so are not really continuous either.

I want to assess

a) the effect of intention on whether participants increased their behavior or not. I expect intended behaviors to increase (positive slope) and non-intended behaviors not to change (no significant slope).

b) the effect of self-control on the increase of environmental behavior, so a self-control x time x environmental behavior interaction.

a) should be the primary focus here, because I don't know how to account for the within-design structure in my model. I'm working with the lmer function in R.

I have to account for a random intercept and slope of ID, as I am expecting participants to have different baselines and developments. So I would start with:

m1 <- lmer (eb ~ time + int ( 1 + time | ID), data = d)


In addition, I should be treating intention as a grouping variable, so I should include ( 1 | intention).

m2 <- lmer (eb ~ time + int ( 1 + time | ID) +  (1 | intention), data = d)


How do I account for the fact that all IDs are in both groups? Do I have to account for that intention is not changing over time? Which other random effects should be included? I have read through a lot of literature, but can't really find an example that is similar to mine. I have played around a bit with different models, but I'm really lacking an understanding of what I'm modelling with different random effects.

• Did all participants intend to change the same environmental behavior? Or was that randomly assigned? If the latter, you should account for that. Apr 28 at 16:06
• Participants chose a behavior they wanted to change (the intended behavior), so the behavior varies across paricipants. Here I'm only interested whether they increased it or not, so it is just coded as the frequency of the behavior. The behavior that was not intended was actually randomly assigned. How can I account for that? Apr 28 at 21:09

It doesn't sound like you are sampling intentions from a population, so I wouldn't use those as a clustering variable. I would use the following:

m3 <- lme4::lmer(eb ~ time * intention + (1 + time | ID), data = d)


Additionally, if you want to handle the ordinal nature of your eb variable and wouldn't mind using Bayesian estimation, you could use the following:

m4 <- brms::brm(
eb ~ time * intention + (1 + time | ID),
family = cumulative(),
data = d,
prior = c(...)
)


I'd also recommend setting some weakly informative priors for the slopes, but without more information about your data, that would be hard for me to guess on.

Bürkner, P.-C. (2017). brms: An R package for Bayesian multilevel models using Stan. Journal of Statistical Software, 80(1), 1–28. https://doi.org/10/gddxwp

Bürkner, P.-C., & Vuorre, M. (2019). Ordinal regression models in psychology: A tutorial. Advances in Methods and Practices in Psychological Science, 2(1), 77–101. https://doi.org/10/gfv26q

• I think this formula is usually used when assessing a treatment effect, and in that case people are only in the treatment OR the control condition (so I would only have three rows per participant and the IDs in both conditions are different ones). In my case every participant is in two conditions at the same time, so I'm wondering how the lmer formula knows that, when specifying eb ~ time * intention + (1 + time | ID)? I guess this formula would be accurat when every ID is only in one condition? Or is that difference not important? Apr 28 at 21:16