-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
[fix] estimate_grouplevel() #429
Conversation
One main improvement is to sanitize the brms naming to be closer to standard outputs, but it requires some regex data <- iris
data$Group <- as.factor(rep(c("G1", "G2", "G3"), each = 50))
model <- glmmTMB::glmmTMB(Sepal.Width ~ Petal.Width + (Petal.Width | Group), data = data)
modelbased::estimate_grouplevel(model)
#> Group | Level | Parameter | Coefficient | SE | 95% CI | Component
#> ------------------------------------------------------------------------------
#> Group | G1 | (Intercept) | 1.08 | 0.47 | [ 0.15, 2.00] | conditional
#> Group | G1 | Petal.Width | -5.19e-03 | 0.29 | [-0.58, 0.57] | conditional
#> Group | G2 | (Intercept) | -0.40 | 0.57 | [-1.51, 0.71] | conditional
#> Group | G2 | Petal.Width | 0.01 | 0.29 | [-0.56, 0.59] | conditional
#> Group | G3 | (Intercept) | -0.68 | 0.55 | [-1.75, 0.40] | conditional
#> Group | G3 | Petal.Width | -9.56e-03 | 0.21 | [-0.42, 0.40] | conditional
model <- brms::brm(Sepal.Width ~ Petal.Width + (Petal.Width | Group), data = data, refresh=0)
modelbased::estimate_grouplevel(model)
#> Group | Level | Parameter
#> -------------------------------------------------------------------
#> Group | (Intercept) | sd_Group__Intercept
#> Group | Group.G1 | r_Group[G1,Intercept]
#> Group | Group.G1 | r_Group[G1,Petal.Width]
#> Group | Group.G2 | r_Group[G2,Intercept]
#> Group | Group.G2 | r_Group[G2,Petal.Width]
#> Group | Group.G3 | r_Group[G3,Intercept]
#> Group | Group.G3 | r_Group[G3,Petal.Width]
#> Group | Intercept ~ Petal.Width | cor_Group__Intercept__Petal.Width
#> Group | Petal.Width | sd_Group__Petal.Width
#>
#> Group | Component | Median | 95% CI
#> ----------------------------------------------
#> Group | conditional | 1.38 | [ 0.53, 4.47]
#> Group | conditional | 1.12 | [-0.70, 3.30]
#> Group | conditional | 4.85e-03 | [-0.81, 0.85]
#> Group | conditional | -0.51 | [-2.40, 1.60]
#> Group | conditional | 0.06 | [-0.54, 0.86]
#> Group | conditional | -0.47 | [-2.40, 1.66]
#> Group | conditional | -0.09 | [-0.91, 0.51]
#> Group | conditional | -0.04 | [-0.94, 0.93]
#> Group | conditional | 0.35 | [ 0.02, 1.59] Created on 2025-03-01 with reprex v2.1.1 |
I can review this PR tomorrow or on Monday, if you like. Will be away now. |
Looks good! (though I can't judge all the regex stuff, hehe...) |
I added some models (commented off) in the test that I think are good for testing (lme4, glmmTMB & brms) |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Ok, examples should work now |
Do you want to open another PR for the |
yeah, I was eager to merge something today ^^ |
deviation=TRUE
argumentAdd theNo need anymore, can just filter the outputindices="all"
andgroup="all"
filtering capabilities (available inreshape_grouplevel()
) as part of the main function tootype
argument doesn't work for brms (better addressed in Add option to pull coef() instead of ranef() for random effects parameters#1067)