Margins() with lmer: R equivalent to Stata's at((mean) _all var = (10_percentile, 90_percentile))?

Hi there. I am wondering if there is any argument or function in R that sets all variables equal to their means within the margins() command? I am trying to replicate the Stata code:

margins, at((mean) _all H_citytract_multi_i=(.23 .54))

Is there a way to do this besides manually setting all variables equal to their means in the R? E.g. something like:

marg_1 <- margins(m1, at = list(H_citytract_multi_i = c(.23, .54),
                               diversityinterp = mean(rp$diversityinterp, na.rm = T),
                               pctasianpopinterp = mean(rp$pctasianpopinterp, na.rm = T),
                               pctblkpopinterp = mean(rp$pctblkpopinterp, na.rm = T),

This is very tedious with a large number of variables, and I was hoping to find something that dealt with factors/indicators like Stata does in this case.

Thank you!

There are probably a few ways to do this, given representative data. Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.