rvlenth / emmeans

Estimated marginal means
https://rvlenth.github.io/emmeans/
348 stars 31 forks source link

Bug with nuisance factors in multivariate models #503

Closed rvlenth closed 1 month ago

rvlenth commented 1 month ago

This is a bug that was revealed in an issue with the brms package. There is a typo in the code for .basis.nuis(). In the case of multivariate models, we have an index set ra for the grid, and another index RA that is an expansion of ra for the multivariate levels, and we used the wrong one in the final step where we pull out the relevant grid rows. This results in a corrupted grid.

rvlenth commented 1 month ago

The brms issue also helped identify an additional issue with nuisance factors in general, and that is that they can't be used when emm_basis() performs re-gridding, because the columns of X are no longer associated with model terms.