report
report copied to clipboard
Odds Ratio
Is there a way to change the beta value to an odds ratio for a logistic regression? (exponentiate=T)
Not to me knowledge. I think this option, if existing, would have to be added to parameters::model_parameters()
o, which report()
relies to pull the coefficients. What do the others think?
Maybe report
can use the exponentiate
argument for model_parameters()
?
https://github.com/easystats/parameters/blob/b236ee323036850934d9f94654bf59ed5f42a272/R/1_model_parameters.R#L274
Ah I forgot about that 😅
m <- glm(vs ~ mpg, data = mtcars, family = "binomial")
report::report(m, exponentiate = TRUE)
#> Error in effectsize::interpret_oddsratio(table[[estimate]], log = TRUE, : unused argument (exponentiate = TRUE)
Created on 2021-06-09 by the reprex package (v1.0.0)
It requires to allow dots in interpret_*, will add that and see how it goes
I'm a bit confused, this issue was posted in the parameters repository, and you can return odds ratios by setting exponentiate = TRUE
- does this resolve your issue, @jagunter88 ?
See examples here: https://easystats.github.io/parameters/articles/model_parameters.html#regressions-glms-mixed-models-gams-
Ah, just saw it came from report ... transferring it back then.
It should work with the latest effectsize:
m <- glm(vs ~ mpg, data = mtcars, family = "binomial")
report::report(m, exponentiate = TRUE)
#> We fitted a logistic model (estimated using ML) to predict vs with mpg (formula: vs ~ mpg). The model's explanatory power is substantial (Tjur's R2 = 0.47). The model's intercept, corresponding to mpg = 0, is at 1.46e-04 (95% CI [5.39e-08, 0.02], p < .01). Within this model:
#>
#> - The effect of mpg is statistically significant and positive (beta = 1.54, 95% CI [1.20, 2.28], p < .01; Std. beta = 13.38, 95% CI [3.05, 143.87])
#>
#> Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using
Created on 2021-06-10 by the reprex package (v1.0.0)
@DominiqueMakowski The label should change from "beta" to "OR" or "odds ratio" when exponentiate = TRUE and family = binomial.
model_parameters()
saves the coefficient name as attribute coefficient_name
.
m <- glm(vs ~ mpg, data = mtcars, family = "binomial")
parameters::parameters(m, exponentiate = TRUE) |> str()
#> Classes 'parameters_model', 'see_parameters_model' and 'data.frame': 2 obs. of 9 variables:
#> $ Parameter : chr "(Intercept)" "mpg"
#> $ Coefficient: num 0.000146 1.537893
#> $ SE : num 0.000461 0.243636
#> $ CI : num 0.95 0.95
#> $ CI_low : num 5.39e-08 1.20
#> $ CI_high : num 0.0202 2.2806
#> $ z : num -2.79 2.72
#> $ df_error : num Inf Inf
#> $ p : num 0.00522 0.00659
#> - attr(*, "sigma")= num 0.923
#> - attr(*, "residual_df")= num 30
#> - attr(*, "pretty_names")= Named chr [1:2] "(Intercept)" "mpg"
#> ..- attr(*, "names")= chr [1:2] "(Intercept)" "mpg"
#> - attr(*, "ci")= num 0.95
#> - attr(*, "verbose")= logi TRUE
#> - attr(*, "exponentiate")= logi TRUE
#> - attr(*, "ordinal_model")= logi FALSE
#> - attr(*, "linear_model")= logi FALSE
#> - attr(*, "mixed_model")= logi FALSE
#> - attr(*, "n_obs")= int 32
#> - attr(*, "model_class")= chr [1:2] "glm" "lm"
#> - attr(*, "bootstrap")= logi FALSE
#> - attr(*, "iterations")= num 1000
#> - attr(*, "df_method")= chr "profile"
#> - attr(*, "ignore_group")= logi TRUE
#> - attr(*, "ran_pars")= logi TRUE
#> - attr(*, "show_summary")= logi FALSE
#> - attr(*, "title")= chr ""
#> - attr(*, "weighted_nobs")= num 32
#> - attr(*, "model_formula")= chr "vs ~ mpg"
#> - attr(*, "coefficient_name")= chr "Odds Ratio"
#> - attr(*, "zi_coefficient_name")= chr "Odds Ratio"
#> - attr(*, "digits")= num 2
#> - attr(*, "ci_digits")= num 2
#> - attr(*, "p_digits")= num 3
#> - attr(*, "footer_digits")= num 3
#> - attr(*, "object_name")= chr "m"
Created on 2021-06-11 by the reprex package (v2.0.0)