# Model constraint

• Operating System: macOS High Sierra
• brms Version: 2.6.0

Say I have a model with two predictors and an intercept. E.g.,

``````fit1 <-
brm(data = my_data,
family = gaussian,
y ~ 1 + x1 + x2)
``````

I’d like to constrain the model such that the sum of `x1` and `x2` equals 0. What would the syntax for such a constraint be?

What exactly should be contraint? The predictor values, their regression coefficients, their linear predictor contributions?

1 Like

Let’s say just the coefficients, which must both be positive and sum to a constant (e,g., 1). I’ve seen this question a lot and would appreciate knowing if there is a straightforward way in brms to code it. Perhaps the coefficients could be forced into a simplex?

These kinds of constraints are currently not supported in brms.

Paul, pardon me for not following through with the comment. I found an alternative related to the original question.

However, I have been wondering about the answer to a more general question, such as posed by bachlaw. Coming from an SEM background, I’m used to being able to fix parameters in a variety of ways, such as setting two parameters to equality (e.g., fixing loadings to equality across groups in factorial invariance models). Is it correct that these kinds of equality constraints are also not supported in brms?

You can constrain parameters to be equal using the non-linear framework of brms. This is not super elegant though. Suppose you want to set the two coefficients of x1 and x2 to equality, you can do something like:

``````bf(
y ~ eta + a * x1 + a * x2,
eta ~ <standard formula for the remaining predictors>,
a ~ 1,
nl = TRUE
)
``````
1 Like

Ah, that’s perfectly clear. Thanks, Paul!