JWiley / brmsmargins

Average marginal estimates for Bayesian models fit with the brms package
https://joshuawiley.com/brmsmargins
Other
20 stars 2 forks source link

support centered, categorical predictors #7

Closed JWiley closed 2 years ago

JWiley commented 2 years ago

In multilevel data, categorical predictors should be centered:

Yaremych, H. E., Preacher, K. J., & Hedeker, D. (2021). Centering categorical predictors in multilevel models: Best practices and interpretation. Psychological Methods.

Marginal effects on categorical predictors (e.g., using dummy coding) typically hold values at "0" and "1" and take the difference in the marginal predictions. This breaks when centering by cluster. Instead, plan is to implement something like:

at = c("Low", "High")

for categorical predictors centered by cluster. Approach is to set the categorical predictors at the "0" and "1" values for each individual person. That is, set the "observed" value at 1, then center using the existing mean, then predict. Repeat setting the "observed" value at 1, then center, then predict. The figure below is an example of this. image