-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
make parameters()
show fixed effects restricted to 0
#902
Conversation
Codecov Report
@@ Coverage Diff @@
## main #902 +/- ##
==========================================
- Coverage 57.56% 57.31% -0.25%
==========================================
Files 186 186
Lines 13785 13857 +72
==========================================
+ Hits 7935 7942 +7
- Misses 5850 5915 +65
|
ooooh, i'm excited about this! |
This comment was marked as outdated.
This comment was marked as outdated.
love it! |
Not sure how to print |
Maybe the (ref.) is superfluous? The estimate is 0 and the std errors NULL, so it's quite evident what is happening, and removing "ref." would make things uniform in the term names. If you think they're really necessary, I would put it outside the brackets to have consistent labels (and to make it easier for downstream packages like mine to remove "ref." if we don't want it using regexes. Just a thought. |
I have no better model at hand, here's an example for glm: data(mtcars)
mtcars$cyl <- as.factor(mtcars$cyl)
mtcars$am <- as.factor(mtcars$am)
m <- glm(vs ~ cyl + gear + am, mtcars, family = binomial())
parameters::parameters(m)
#> Parameter | Log-Odds | SE | 95% CI | z | p
#> ------------------------------------------------------------------------------
#> (Intercept) | 151.52 | 71190.45 | [-16813.63, 52679.23] | 2.13e-03 | 0.998
#> cyl [6] | -43.16 | 23084.31 | [-36096.45, -21647.68] | -1.87e-03 | 0.999
#> cyl [8] | -109.42 | 41823.10 | [ , 2786.97] | -2.62e-03 | 0.998
#> gear | -21.78 | 13269.07 | [ , 2712.57] | -1.64e-03 | 0.999
#> am [1] | -42.63 | 25814.34 | [ , 3345.63] | -1.65e-03 | 0.999
#>
#> Uncertainty intervals (profile-likelihood) and p-values (two-tailed)
#> computed using a Wald z-distribution approximation.
#>
#> The model has a log- or logit-link. Consider using `exponentiate =
#> TRUE` to interpret coefficients as ratios.
print(parameters::parameters(m), add_reference = TRUE)
#> Parameter | Log-Odds | SE | 95% CI | z | p
#> ---------------------------------------------------------------------------------
#> (Intercept) | 151.52 | 71190.45 | [-16813.63, 52679.23] | 2.13e-03 | 0.998
#> cyl [4] (ref.) | 0.00 | | | |
#> cyl [6] | -43.16 | 23084.31 | [-36096.45, -21647.68] | -1.87e-03 | 0.999
#> cyl [8] | -109.42 | 41823.10 | [ , 2786.97] | -2.62e-03 | 0.998
#> gear | -21.78 | 13269.07 | [ , 2712.57] | -1.64e-03 | 0.999
#> am [0] (ref.) | 0.00 | | | |
#> am [1] | -42.63 | 25814.34 | [ , 3345.63] | -1.65e-03 | 0.999
#>
#> Uncertainty intervals (profile-likelihood) and p-values (two-tailed)
#> computed using a Wald z-distribution approximation.
print(parameters::parameters(m, exponentiate = TRUE), add_reference = TRUE)
#> Parameter | Odds Ratio | SE | 95% CI | z | p
#> -----------------------------------------------------------------------------
#> (Intercept) | 6.37e+65 | 4.54e+70 | [0.00, Inf] | 2.13e-03 | 0.998
#> cyl [4] (ref.) | 1.00 | | | |
#> cyl [6] | 1.80e-19 | 4.14e-15 | [0.00, 0.00] | -1.87e-03 | 0.999
#> cyl [8] | 3.01e-48 | 1.26e-43 | [ , Inf] | -2.62e-03 | 0.998
#> gear | 3.48e-10 | 4.62e-06 | [ , Inf] | -1.64e-03 | 0.999
#> am [0] (ref.) | 1.00 | | | |
#> am [1] | 3.06e-19 | 7.91e-15 | [ , Inf] | -1.65e-03 | 0.999
#>
#> Uncertainty intervals (profile-likelihood) and p-values (two-tailed)
#> computed using a Wald z-distribution approximation. Created on 2023-09-11 with reprex v2.0.2 |
Yes, it could be removed, indeed. |
when dropping coefficients, or models with multiple components whould work now, too: library(parameters)
data("fish")
m1 <- glmmTMB::glmmTMB(
count ~ child + camper + zg + (1 | ID),
ziformula = ~ child + camper + (1 | persons),
data = fish,
family = glmmTMB::truncated_poisson()
)
print(model_parameters(m1), add_reference = TRUE)
#> # Fixed Effects (Count Model)
#>
#> Parameter | Log-Mean | SE | 95% CI | z | p
#> ---------------------------------------------------------------------
#> (Intercept) | 1.41 | 0.18 | [ 1.06, 1.75] | 8.02 | < .001
#> child | -0.53 | 0.12 | [-0.77, -0.29] | -4.40 | < .001
#> camper [0] (ref.) | 0.00 | | | |
#> camper [1] | 0.58 | 0.10 | [ 0.39, 0.78] | 5.93 | < .001
#> zg | 0.13 | 0.04 | [ 0.05, 0.21] | 3.17 | 0.002
#>
#> # Fixed Effects (Zero-Inflation Component)
#>
#> Parameter | Log-Odds | SE | 95% CI | z | p
#> ---------------------------------------------------------------------
#> (Intercept) | -0.39 | 0.65 | [-1.67, 0.89] | -0.60 | 0.551
#> child | 2.05 | 0.31 | [ 1.45, 2.66] | 6.63 | < .001
#> camper [0] (ref.) | 0.00 | | | |
#> camper [1] | -1.01 | 0.32 | [-1.64, -0.37] | -3.12 | 0.002
#>
#> # Random Effects Variances
#>
#> Parameter | Coefficient | 95% CI
#> -----------------------------------------------
#> SD (Intercept: ID) | 0.28 | [0.13, 0.60]
#>
#> # Random Effects (Zero-Inflation Component)
#>
#> Parameter | Coefficient | 95% CI
#> ----------------------------------------------------
#> SD (Intercept: persons) | 1.17 | [0.54, 2.57]
#>
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#> using a Wald z-distribution approximation.
#>
#> The model has a log- or logit-link. Consider using `exponentiate =
#> TRUE` to interpret coefficients as ratios.
data(mtcars)
mtcars$gear <- as.factor(mtcars$gear)
m <- glm(vs ~ wt + gear, data = mtcars, family = "binomial")
print(model_parameters(m, exponentiate = TRUE, drop = "(Intercept)"), add_reference = TRUE)
#> Parameter | Odds Ratio | SE | 95% CI | z | p
#> -------------------------------------------------------------------
#> wt | 0.07 | 0.09 | [0.00, 0.52] | -2.05 | 0.040
#> gear [3] (ref.) | 1.00 | | | |
#> gear [4] | 3.21 | 3.98 | [0.27, 41.36] | 0.94 | 0.348
#> gear [5] | 0.03 | 0.07 | [0.00, 1.47] | -1.41 | 0.159
#>
#> Uncertainty intervals (profile-likelihood) and p-values (two-tailed)
#> computed using a Wald z-distribution approximation. Created on 2023-09-11 with reprex v2.0.2 |
ok, I removed |
This comment was marked as off-topic.
This comment was marked as off-topic.
What's not yet properly working could be if the reference level is changed, e.g. to the last level (see screenshot in #715) |
Fixes #715