# Using random effects as predictors / independent variables

I’m modeling responses to a task in fairly straightforward way. Each person has multiple responses and they are expected to vary as different task factors change. I am allowing each person to have a different mean response, and for the effect of each task factor to vary by person as well. I also have some person-level variables that are constant within person. They are theoretically downstream consequences of the psychological processes being measured by the task, so I do not want to include them as independent variables that predict variation in the group terms / random effects. Rather, I want to use the random effects as latent variables to predict the individual-level variables.

The task might be modeled as:

``````response ~ 1 + factorA + factorB + (1 + factorA + factorB | id)
``````

I would like to be able to regress `indiv_diff` on the id-varying intercept and parameters for factorA and factorB simultaneously. So if, e.g., 1_id is a vector of individually varying intercepts, I’d like to be able to include the formulas `1_id ~ indiv_diff`, `factorA_id ~ indiv_diff`, etc, with each of those variables having length equal to the unique values of grouping variable `id`.

Is this (a) possible, and (b) ridiculous? For example, maybe I should just be using `indiv_diff` without regard to where it lies on the theoretical causal diagram and use the following equation:

``````response ~ 1 + factorA + factorB + indiv_diff + factorA:indiv_diff + factorB:indiv_diff + (1 + factorA + factorB | id)
``````

Sorry, low on time, so just some quick thoughts:

• In maximum likelihood linear regression regressing `indiv_diff` on `x` and `x` on `indiv_diff` is equivalent (if `indiv_diff = b*x` then `x = (1/b) * indiv_diff`). With priors (and when treating varying intercepts) those are no longer strictly equivalent, but I still doubt you gain anything interesting
• Some of the functionality you seem to need looks similar to multivariete models.

Hope that helps!

It seems you want to set up a latent variable/structural equation model with brms, right?

This is not yet possible with brms, but will be possible with brms version 3.0.

1 Like

@paul.buerkner, yep, that’s right. That’s really amazing news, I didn’t know you all were pursuing that functionality. That will be such a boon to researchers wanting to easily implement, e.g., DSEM, or in an extension of the specific example I gave, non-linear models with latent parameters as IVs.

@martinmodrak, thanks for the advice. I think for many practical purposes you’re right about your first point, but I know some people would find that formulation problematic. With the multivariate model I think you’re suggesting something like, where `indiv_diff_items` should be the items that go into computing the scale score, `indiv_diff`; I can then look at the correlation between the random terms linked by `q`:

``````fit <- brm(
bf(response ~ 1 + factorA + factorB + (1 + factorA + factorB | q | id)) +
bf(indiv_diff_items ~ 1 + (1 | q | id)),
data = data)
``````