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

Missing Response column for categorical models for {marginaleffects} objects #692

Closed
strengejacke opened this issue Jan 18, 2025 · 0 comments · Fixed by #701
Closed

Missing Response column for categorical models for {marginaleffects} objects #692

strengejacke opened this issue Jan 18, 2025 · 0 comments · Fixed by #701
Assignees
Labels
Bug 🐛 Something isn't working

Comments

@strengejacke
Copy link
Member

m <- insight::download_model("brms_categorical_1_num")
m
#>  Family: categorical 
#>   Links: mu4 = logit; mu5 = logit 
#> Formula: gear ~ mpg 
#>    Data: mtcars (Number of observations: 32) 
#>   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
#>          total post-warmup draws = 4000
#> 
#> Regression Coefficients:
#>               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
#> mu4_Intercept   -11.28      3.56   -19.03    -5.29 1.00     1799     2230
#> mu5_Intercept    -8.88      3.49   -16.56    -2.87 1.00     1640     1883
#> mu4_mpg           0.57      0.18     0.26     0.96 1.00     1625     1987
#> mu5_mpg           0.42      0.18     0.10     0.81 1.00     1500     1695
#> 
#> Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
#> and Tail_ESS are effective sample size measures, and Rhat is the potential
#> scale reduction factor on split chains (at convergence, Rhat = 1).
out <- modelbased::get_marginalmeans(m, by = "mpg = [sd]")
#> Warning in check_dep_version(dep_pkg = "TMB"): package version mismatch: 
#> glmmTMB was built with TMB package version 1.9.15
#> Current TMB package version is 1.9.16
#> Please re-install glmmTMB from source or restore original 'TMB' package (see '?reinstalling' for more information)
out
#> 
#>  Group Estimate   2.5 % 97.5 %
#>      3   0.8982 0.66528  0.988
#>      3   0.3545 0.15055  0.597
#>      3   0.0250 0.00112  0.180
#>      4   0.0368 0.00319  0.182
#>      4   0.4026 0.19001  0.651
#>      4   0.7736 0.50293  0.944
#>      5   0.0496 0.00474  0.231
#>      5   0.2204 0.07426  0.452
#>      5   0.1819 0.03681  0.449
#> 
#> Type:  response
bayestestR::describe_posterior(out)
#> Summary of Posterior Distribution
#> 
#> mpg   | Median |       95% CI |   pd |          ROPE | % in ROPE
#> ----------------------------------------------------------------
#> 14.06 |   0.90 | [0.67, 0.99] | 100% | [-0.10, 0.10] |        0%
#> 20.09 |   0.35 | [0.15, 0.60] | 100% | [-0.10, 0.10] |        0%
#> 26.12 |   0.02 | [0.00, 0.18] | 100% | [-0.10, 0.10] |    91.79%
#> 14.06 |   0.04 | [0.00, 0.18] | 100% | [-0.10, 0.10] |    88.11%
#> 20.09 |   0.40 | [0.19, 0.65] | 100% | [-0.10, 0.10] |        0%
#> 26.12 |   0.77 | [0.50, 0.94] | 100% | [-0.10, 0.10] |        0%
#> 14.06 |   0.05 | [0.00, 0.23] | 100% | [-0.10, 0.10] |    79.66%
#> 20.09 |   0.22 | [0.07, 0.45] | 100% | [-0.10, 0.10] |     3.97%
#> 26.12 |   0.18 | [0.04, 0.45] | 100% | [-0.10, 0.10] |    18.05%

Created on 2025-01-18 with reprex v2.1.1

@strengejacke strengejacke added the Bug 🐛 Something isn't working label Jan 18, 2025
@strengejacke strengejacke self-assigned this Feb 20, 2025
strengejacke added a commit that referenced this issue Feb 20, 2025
…} objects (#701)

* Missing `Response` column for categorical models for {marginaleffects} objects
Fixes #692

* more robust

* wordlist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant