Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to omit triangle in variance-covariance matrices? #208

Open
andrewheiss opened this issue Jan 6, 2022 · 1 comment
Open

Add option to omit triangle in variance-covariance matrices? #208

andrewheiss opened this issue Jan 6, 2022 · 1 comment

Comments

@andrewheiss
Copy link
Collaborator

When estimating lme4 models with multiple random slopes, the results include variances (σ²) and covariances (ρ) for each of the terms and their random intercepts, like female (β1) and ses (β2) and their intercepts (α) here:

library(lme4)
library(equatiomatic)

hsb2 <- lmer(
  math ~ female + ses + minority + (female + ses | sch.id),
  hsb
)
extract_eq(hsb2)

operatorname_mat

There's a lot of duplicated information in the variance/covariance matrix (ρ_αjβ1j vs. ρ_β1jαj). One really neat solution to this that I recently came across (in https://doi.org/10.1111/2041-210X.13755) is to omit the covariances in the bottom triangle and replace them with \dots, which looks a lot cleaner, especially for bigger models (here's equation 30 from that paper):

image

In equatiomatic, hsb2 could look something like this:

operatorname_mat-1

I'm not sure how complicated the code is for creating that array LaTeX environment, but adding (yet another) argument to extract_eq() that runs something like covar_matrix[lower.tri(covar_matrix)] <- "\dots" behind the scenes could be a neat addition.

@andrewheiss andrewheiss changed the title Add option to omit diagonal in variance matrices? Add option to omit triangle in variance-covariance matrices? Jan 6, 2022
@datalorax
Copy link
Owner

I like it. I'll be honest in saying I'm a bit burned out with this package at the moment though so I can't promise that it will be implemented anytime real soon, but I do think it's worth implementing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants