Convert change in probability to probability / odds#676
Merged
Conversation
Contributor
|
Maybe "risk" instead of "probs" |
Member
Author
|
We already have |
Member
Author
m1 <- glm(am ~ factor(cyl),
family = binomial("logit"),
data = mtcars)
m2 <- glm(am ~ factor(cyl),
family = binomial("log"),
data = mtcars)
effectsize::oddsratio_to_arr(m1)
#> Warning: 'p0' not provided:
#> Computing effect size relative to the intercept (p0 = 0.727);
#> Make sure your intercept is meaningful.
#> Parameter | ARR | 95% CI
#> ----------------------------------
#> (p0) | 0.73 |
#> cyl [6] | -0.30 | [-0.65, 0.11]
#> cyl [8] | -0.58 | [-0.71, -0.22]
#>
#> Uncertainty intervals (profile-likelihood) and p-values (two-tailed)
#> computed using a Wald z-distribution approximation.
effectsize::riskratio_to_arr(m2)
#> Warning: 'p0' not provided:
#> Computing effect size relative to the intercept (p0 = 0.727);
#> Make sure your intercept is meaningful.
#> Parameter | ARR | 95% CI
#> ----------------------------------
#> (p0) | 0.73 |
#> cyl [6] | -0.30 | [-0.60, 0.23]
#> cyl [8] | -0.58 | [-0.70, -0.30]
#>
#> Uncertainty intervals (profile-likelihood) and p-values (two-tailed)
#> computed using a Wald z-distribution approximation.
effectsize::oddsratio_to_riskratio(m1)
#> Warning: 'p0' not provided:
#> Computing effect size relative to the intercept (p0 = 0.727);
#> Make sure your intercept is meaningful.
#> Parameter | Risk ratio | 95% CI
#> -------------------------------------
#> (p0) | 0.73 |
#> cyl [6] | 0.59 | [0.11, 1.16]
#> cyl [8] | 0.20 | [0.02, 0.70]
#>
#> Uncertainty intervals (profile-likelihood) and p-values (two-tailed)
#> computed using a Wald z-distribution approximation.
parameters::model_parameters(m2, exp = TRUE)
#> Parameter | Risk Ratio | SE | 95% CI | z | p
#> --------------------------------------------------------------
#> (Intercept) | 0.73 | 0.13 | [0.44, 0.92] | -1.72 | 0.085
#> cyl [6] | 0.59 | 0.28 | [0.17, 1.31] | -1.12 | 0.264
#> cyl [8] | 0.20 | 0.13 | [0.03, 0.59] | -2.39 | 0.017
#>
#> Uncertainty intervals (profile-likelihood) and p-values (two-tailed)
#> computed using a Wald z-distribution approximation.
effectsize::riskratio_to_oddsratio(m2)
#> Warning: 'p0' not provided:
#> Computing effect size relative to the intercept (p0 = 0.727);
#> Make sure your intercept is meaningful.
#> Parameter | Odds ratio | 95% CI
#> -------------------------------------
#> (p0) | 0.73 |
#> cyl [6] | 0.28 | [0.05, 7.54]
#> cyl [8] | 0.06 | [0.01, 0.28]
#>
#> Uncertainty intervals (profile-likelihood) and p-values (two-tailed)
#> computed using a Wald z-distribution approximation.
parameters::model_parameters(m1, exp = TRUE)
#> Parameter | Odds Ratio | SE | 95% CI | z | p
#> ---------------------------------------------------------------
#> (Intercept) | 2.67 | 1.81 | [0.77, 12.17] | 1.45 | 0.147
#> cyl [6] | 0.28 | 0.29 | [0.03, 1.99] | -1.24 | 0.214
#> cyl [8] | 0.06 | 0.06 | [0.01, 0.39] | -2.72 | 0.007
#>
#> Uncertainty intervals (profile-likelihood) and p-values (two-tailed)
#> computed using a Wald z-distribution approximation.Created on 2025-07-19 with reprex v2.1.1 |
Contributor
|
What did you mean by?
|
Member
Author
|
There used to be a method for |
bwiernik
reviewed
Jul 22, 2025
Co-authored-by: Brenton M. Wiernik <bwiernik@users.noreply.github.com>
Co-authored-by: Brenton M. Wiernik <bwiernik@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #660
oddsratio_to_<change>()functions work with a binomial logistic model.riskratio_to_<change>()functions work with a binomial log-link model.probs_to_odds(<data.frame>)andodds_to_probs(<data.frame>)- suggest something else instead.