Title: | Tipping Point Analyses |
---|---|
Description: | The strength of evidence provided by epidemiological and observational studies is inherently limited by the potential for unmeasured confounding. We focus on three key quantities: the observed bound of the confidence interval closest to the null, the relationship between an unmeasured confounder and the outcome, for example a plausible residual effect size for an unmeasured continuous or binary confounder, and the relationship between an unmeasured confounder and the exposure, for example a realistic mean difference or prevalence difference for this hypothetical confounder between exposure groups. Building on the methods put forth by Cornfield et al. (1959), Bross (1966), Schlesselman (1978), Rosenbaum & Rubin (1983), Lin et al. (1998), Lash et al. (2009), Rosenbaum (1986), Cinelli & Hazlett (2020), VanderWeele & Ding (2017), and Ding & VanderWeele (2016), we can use these quantities to assess how an unmeasured confounder may tip our result to insignificance. |
Authors: | Lucy D'Agostino McGowan [aut, cre] , Malcolm Barrett [aut] |
Maintainer: | Lucy D'Agostino McGowan <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.2.9000 |
Built: | 2024-11-18 06:10:21 UTC |
Source: | https://github.com/r-causal/tipr |
Adjust an observed regression coefficient for a normally distributed confounder
adjust_coef( effect_observed, exposure_confounder_effect, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE) ) adjust_coef_with_continuous( effect_observed, exposure_confounder_effect, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE) )
adjust_coef( effect_observed, exposure_confounder_effect, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE) ) adjust_coef_with_continuous( effect_observed, exposure_confounder_effect, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE) )
effect_observed |
Numeric. Observed exposure - outcome effect from a regression model. This can be the beta coefficient, the lower confidence bound of the beta coefficient, or the upper confidence bound of the beta coefficient. |
exposure_confounder_effect |
Numeric. Estimated difference in scaled means between the unmeasured confounder in the exposed population and unexposed population |
confounder_outcome_effect |
Numeric. Estimated relationship between the unmeasured confounder and the outcome. |
verbose |
Logical. Indicates whether to print informative message.
Default: |
Data frame.
## Update an observed coefficient of 0.5 with an unmeasured confounder ## with a difference in scaled means between exposure groups of 0.2 ## and coefficient of 0.3 adjust_coef(0.5, 0.2, 0.3)
## Update an observed coefficient of 0.5 with an unmeasured confounder ## with a difference in scaled means between exposure groups of 0.2 ## and coefficient of 0.3 adjust_coef(0.5, 0.2, 0.3)
Adjust an observed coefficient from a regression model with a binary confounder
adjust_coef_with_binary( effect_observed, exposed_confounder_prev, unexposed_confounder_prev, confounder_outcome_effect, loglinear = FALSE, verbose = getOption("tipr.verbose", TRUE) )
adjust_coef_with_binary( effect_observed, exposed_confounder_prev, unexposed_confounder_prev, confounder_outcome_effect, loglinear = FALSE, verbose = getOption("tipr.verbose", TRUE) )
effect_observed |
Numeric. Observed exposure - outcome effect from a loglinear model. This can be the beta coefficient, the lower confidence bound of the beta coefficient, or the upper confidence bound of the beta coefficient. |
exposed_confounder_prev |
Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the exposed population |
unexposed_confounder_prev |
Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the unexposed population |
confounder_outcome_effect |
Numeric. Estimated relationship between the unmeasured confounder and the outcome. |
loglinear |
Logical. Calculate the adjusted coefficient from a loglinear
model instead of a linear model (the default). When |
verbose |
Logical. Indicates whether to print informative message.
Default: |
Data frame.
adjust_coef_with_binary(1.1, 0.5, 0.3, 1.3)
adjust_coef_with_binary(1.1, 0.5, 0.3, 1.3)
This function wraps the sensemakr::adjusted_estimate()
and
sensemakr::adjusted_se()
functions.
adjust_coef_with_r2( effect_observed, se, df, confounder_exposure_r2, confounder_outcome_r2, verbose = getOption("tipr.verbose", TRUE), alpha = 0.05, ... )
adjust_coef_with_r2( effect_observed, se, df, confounder_exposure_r2, confounder_outcome_r2, verbose = getOption("tipr.verbose", TRUE), alpha = 0.05, ... )
effect_observed |
Numeric. Observed exposure - outcome effect from a regression model. This is the point estimate (beta coefficient) |
se |
Numeric. Standard error of the |
df |
Numeric positive value. Residual degrees of freedom for the model used to estimate the observed exposure - outcome effect. This is the total number of observations minus the number of parameters estimated in your model. Often for models estimated with an intercept this is N - k - 1 where k is the number of predictors in the model. |
confounder_exposure_r2 |
Numeric value between 0 and 1. The assumed partial R2 of the unobserved confounder with the exposure given the measured covariates. |
confounder_outcome_r2 |
Numeric value between 0 and 1. The assumed partial R2 of the unobserved confounder with the outcome given the exposure and the measured covariates. |
verbose |
Logical. Indicates whether to print informative message.
Default: |
alpha |
Significance level. Default = |
... |
Optional arguments passed to the |
A data frame.
Carlos Cinelli, Jeremy Ferwerda and Chad Hazlett (2021). sensemakr: Sensitivity Analysis Tools for Regression Models. R package version 0.1.4. https://CRAN.R-project.org/package=sensemakr
adjust_coef_with_r2(0.5, 0.1, 102, 0.05, 0.1)
adjust_coef_with_r2(0.5, 0.1, 102, 0.05, 0.1)
Adjust an observed hazard ratio for a normally distributed confounder
adjust_hr( effect_observed, exposure_confounder_effect, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE), hr_correction = FALSE ) adjust_hr_with_continuous( effect_observed, exposure_confounder_effect, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE), hr_correction = FALSE )
adjust_hr( effect_observed, exposure_confounder_effect, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE), hr_correction = FALSE ) adjust_hr_with_continuous( effect_observed, exposure_confounder_effect, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE), hr_correction = FALSE )
effect_observed |
Numeric positive value. Observed exposure - outcome hazard ratio. This can be the point estimate, lower confidence bound, or upper confidence bound. |
exposure_confounder_effect |
Numeric. Estimated difference in scaled means between the unmeasured confounder in the exposed population and unexposed population |
confounder_outcome_effect |
Numeric. Estimated relationship between the unmeasured confounder and the outcome. |
verbose |
Logical. Indicates whether to print informative message.
Default: |
hr_correction |
Logical. Indicates whether to use a correction factor.
The methods used for this function are based on risk ratios. For rare
outcomes, a hazard ratio approximates a risk ratio. For common outcomes,
a correction factor is needed. If you have a common outcome (>15%),
set this to |
Data frame.
adjust_hr(0.9, -0.9, 1.3)
adjust_hr(0.9, -0.9, 1.3)
Adjust an observed hazard ratio with a binary confounder
adjust_hr_with_binary( effect_observed, exposed_confounder_prev, unexposed_confounder_prev, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE), hr_correction = FALSE )
adjust_hr_with_binary( effect_observed, exposed_confounder_prev, unexposed_confounder_prev, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE), hr_correction = FALSE )
effect_observed |
Numeric positive value. Observed exposure - outcome hazard ratio. This can be the point estimate, lower confidence bound, or upper confidence bound. |
exposed_confounder_prev |
Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the exposed population |
unexposed_confounder_prev |
Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the unexposed population |
confounder_outcome_effect |
Numeric positive value. Estimated relationship between the unmeasured confounder and the outcome |
verbose |
Logical. Indicates whether to print informative message.
Default: |
hr_correction |
Logical. Indicates whether to use a correction factor.
The methods used for this function are based on risk ratios. For rare
outcomes, a hazard ratio approximates a risk ratio. For common outcomes,
a correction factor is needed. If you have a common outcome (>15%),
set this to |
Data frame.
adjust_hr_with_binary(0.8, 0.1, 0.5, 1.8)
adjust_hr_with_binary(0.8, 0.1, 0.5, 1.8)
Adjust an observed odds ratio for a normally distributed confounder
adjust_or( effect_observed, exposure_confounder_effect, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE), or_correction = FALSE ) adjust_or_with_continuous( effect_observed, exposure_confounder_effect, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE), or_correction = FALSE )
adjust_or( effect_observed, exposure_confounder_effect, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE), or_correction = FALSE ) adjust_or_with_continuous( effect_observed, exposure_confounder_effect, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE), or_correction = FALSE )
effect_observed |
Numeric positive value. Observed exposure - outcome odds ratio. This can be the point estimate, lower confidence bound, or upper confidence bound. |
exposure_confounder_effect |
Numeric. Estimated difference in scaled means between the unmeasured confounder in the exposed population and unexposed population |
confounder_outcome_effect |
Numeric. Estimated relationship between the unmeasured confounder and the outcome. |
verbose |
Logical. Indicates whether to print informative message.
Default: |
or_correction |
Logical. Indicates whether to use a correction factor.
The methods used for this function are based on risk ratios. For rare
outcomes, an odds ratio approximates a risk ratio. For common outcomes,
a correction factor is needed. If you have a common outcome (>15%),
set this to |
Data frame.
adjust_or(1.2, 0.9, 1.3)
adjust_or(1.2, 0.9, 1.3)
Adjust an observed odds ratio with a binary confounder
adjust_or_with_binary( effect_observed, exposed_confounder_prev, unexposed_confounder_prev, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE), or_correction = FALSE )
adjust_or_with_binary( effect_observed, exposed_confounder_prev, unexposed_confounder_prev, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE), or_correction = FALSE )
effect_observed |
Numeric positive value. Observed exposure - outcome odds ratio. This can be the point estimate, lower confidence bound, or upper confidence bound. |
exposed_confounder_prev |
Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the exposed population |
unexposed_confounder_prev |
Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the unexposed population |
confounder_outcome_effect |
Numeric positive value. Estimated relationship between the unmeasured confounder and the outcome |
verbose |
Logical. Indicates whether to print informative message.
Default: |
or_correction |
Logical. Indicates whether to use a correction factor.
The methods used for this function are based on risk ratios. For rare
outcomes, an odds ratio approximates a risk ratio. For common outcomes,
a correction factor is needed. If you have a common outcome (>15%),
set this to |
Data frame.
adjust_or_with_binary(3, 1, 0, 3) adjust_or_with_binary(3, 1, 0, 3, or_correction = TRUE)
adjust_or_with_binary(3, 1, 0, 3) adjust_or_with_binary(3, 1, 0, 3, or_correction = TRUE)
Adjust an observed risk ratio for a normally distributed confounder
adjust_rr( effect_observed, exposure_confounder_effect, confounder_outcome_effect, verbose = TRUE ) adjust_rr_with_continuous( effect_observed, exposure_confounder_effect, confounder_outcome_effect, verbose = TRUE )
adjust_rr( effect_observed, exposure_confounder_effect, confounder_outcome_effect, verbose = TRUE ) adjust_rr_with_continuous( effect_observed, exposure_confounder_effect, confounder_outcome_effect, verbose = TRUE )
effect_observed |
Numeric positive value. Observed exposure - outcome risk ratio. This can be the point estimate, lower confidence bound, or upper confidence bound. |
exposure_confounder_effect |
Numeric. Estimated difference in scaled means between the unmeasured confounder in the exposed population and unexposed population |
confounder_outcome_effect |
Numeric. Estimated relationship between the unmeasured confounder and the outcome. |
verbose |
Logical. Indicates whether to print informative message.
Default: |
Data frame.
adjust_rr(1.2, 0.5, 1.1)
adjust_rr(1.2, 0.5, 1.1)
Adjust an observed risk ratio with a binary confounder
adjust_rr_with_binary( effect_observed, exposed_confounder_prev, unexposed_confounder_prev, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE) )
adjust_rr_with_binary( effect_observed, exposed_confounder_prev, unexposed_confounder_prev, confounder_outcome_effect, verbose = getOption("tipr.verbose", TRUE) )
effect_observed |
Numeric positive value. Observed exposure - outcome risk ratio. This can be the point estimate, lower confidence bound, or upper confidence bound. |
exposed_confounder_prev |
Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the exposed population |
unexposed_confounder_prev |
Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the unexposed population |
confounder_outcome_effect |
Numeric positive value. Estimated relationship between the unmeasured confounder and the outcome |
verbose |
Logical. Indicates whether to print informative message.
Default: |
Data frame.
adjust_rr_with_binary(1.1, 0.5, 0.3, 1.3)
adjust_rr_with_binary(1.1, 0.5, 0.3, 1.3)
Calculate an E-value
e_value(effect_observed)
e_value(effect_observed)
effect_observed |
Numeric positive value. Observed exposure - outcome effect (assumed to be the exponentiated coefficient, so a risk ratio, odds ratio, or hazard ratio). This can be the point estimate, lower confidence bound, or upper confidence bound. |
Numeric value
e_value(0.9) e_value(1.3)
e_value(0.9) e_value(1.3)
A data set simulated with two Normally distributed confounders, one "measured" and one "unmeasured", an exposure, and outcome. The "true" causal effect of the exposure on the outcome, accounting for both the measured and unmeasured confounders, should be 0.
exdata_continuous
exdata_continuous
A data frame with 2,000 rows and 4 columns:
.unmeasured_confounder
: A simulated unmeasured confounder
measured_confounder
: A simulated measured confounder
exposure
outcome
A data set simulated with two Normally distributed confounders, one "measured" and one "unmeasured", an exposure, and outcome. The "true" causal effect of the exposure on the outcome, accounting for both the measured and unmeasured confounders, should be 0.
exdata_rr
exdata_rr
A data frame with 2,000 rows and 4 columns:
.unmeasured_confounder
: A simulated unmeasured confounder
measured_confounder
: A simulated measured confounder
exposure
outcome
Order observed bias data frame for plotting
observed_bias_order(d, by)
observed_bias_order(d, by)
d |
Observed bias data frame. Must have columns |
by |
Character. Variable in |
Data frame in the correct order
Create a data frame to assist with creating an observed bias plot
observed_bias_tbl(ps_mod, outcome_mod, drop_list = NULL)
observed_bias_tbl(ps_mod, outcome_mod, drop_list = NULL)
ps_mod |
Model object for the propensity score model |
outcome_mod |
Model object for the outcome model |
drop_list |
Named list of covariates or groups of covariates to drop if
|
Data frame with the following columns:
dropped
: The covariate or group of covariates that were dropped
type
: Explanation of dropped
, whether it refers to a single covariate (covariate
) or a group of covariates (group
)
ps_formula
: The new formula for the updated propensity score model
outcome_formula
: The new formula for the updated outcome model
ps_model
: The new model object for the updated propensity score model
p
: The updated propensity score
ps_mod <- glm(am ~ mpg + cyl + I(hp^2), data = mtcars) outcome_mod <- lm(qsec ~ am + hp + disp + wt, data = mtcars) observed_bias_tbl( ps_mod, outcome_mod, drop_list = list( group_one = c("mpg", "hp"), group_two = c("cyl", "wt") ) )
ps_mod <- glm(am ~ mpg + cyl + I(hp^2), data = mtcars) outcome_mod <- lm(qsec ~ am + hp + disp + wt, data = mtcars) observed_bias_tbl( ps_mod, outcome_mod, drop_list = list( group_one = c("mpg", "hp"), group_two = c("cyl", "wt") ) )
Create a data frame to combine with an observed bias data frame demonstrating a hypothetical unmeasured confounder
observed_bias_tip( tip, point_estimate, lb, ub, tip_desc = "Hypothetical unmeasured confounder" )
observed_bias_tip( tip, point_estimate, lb, ub, tip_desc = "Hypothetical unmeasured confounder" )
tip |
Numeric. Value you would like to tip to. |
point_estimate |
Numeric. Result estimate from the full model. |
lb |
Numeric. Result lower bound from the full model. |
ub |
Numeric. Result upper bound from the full model. |
tip_desc |
Character. A description of the tipping point. |
A data frame with five columns:
dropped
: the input from tip_desc
type
: Explanation of dropped
, here tip
to clarify that this was calculated as a tipping point.
point_estimate
: the shifted point estimate
lb
: the shifted lower bound
ub
: the shifted upper bound
Calculate the Observed Covariate E-value
observed_covariate_e_value(lb, ub, lb_adj, ub_adj, transform = NULL)
observed_covariate_e_value(lb, ub, lb_adj, ub_adj, transform = NULL)
lb |
Numeric. The lower bound of the full model |
ub |
Numeric. The upper bound of the full model |
lb_adj |
Numeric. The lower bound of the adjusted model |
ub_adj |
Numeric. The upper bound of the adjusted model |
transform |
Character. If your effect is an odds ratio or hazard ratio, this will perform the transformation suggested by VanderWeele and Ding. Allowed values are:
|
The Observed Covariate E-value
This function wraps the sensemakr::robustness_value()
function
r_value(effect_observed, se, df, ...)
r_value(effect_observed, se, df, ...)
effect_observed |
Numeric. Observed exposure - outcome effect from a regression model. This is the point estimate (beta coefficient) |
se |
Numeric. Standard error of the |
df |
Numeric positive value. Residual degrees of freedom for the model used to estimate the observed exposure - outcome effect. This is the total number of observations minus the number of parameters estimated in your model. Often for models estimated with an intercept this is N - k - 1 where k is the number of predictors in the model. |
... |
Optional arguments passed to the |
Numeric. Robustness value
Carlos Cinelli, Jeremy Ferwerda and Chad Hazlett (2021). sensemakr: Sensitivity Analysis Tools for Regression Models. R package version 0.1.4. https://CRAN.R-project.org/package=sensemakr
r_value(0.5, 0.1, 102)
r_value(0.5, 0.1, 102)
choose one of the following, and the other will be estimated:
exposure_confounder_effect
confounder_outcome_effect
tip( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), correction_factor = "none" ) tip_with_continuous( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), correction_factor = "none" ) tip_c( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), correction_factor = "none" )
tip( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), correction_factor = "none" ) tip_with_continuous( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), correction_factor = "none" ) tip_c( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), correction_factor = "none" )
effect_observed |
Numeric positive value. Observed exposure - outcome effect (assumed to be the exponentiated coefficient, so a risk ratio, odds ratio, or hazard ratio). This can be the point estimate, lower confidence bound, or upper confidence bound. |
exposure_confounder_effect |
Numeric. Estimated difference in scaled means between the unmeasured confounder in the exposed population and unexposed population |
confounder_outcome_effect |
Numeric positive value. Estimated relationship between the unmeasured confounder and the outcome |
verbose |
Logical. Indicates whether to print informative message.
Default: |
correction_factor |
Character string. Options are "none", "hr", "or". For common outcomes (>15%), the odds ratio or hazard ratio is not a good estimate for the risk ratio. In these cases, we can apply a correction factor. If you are supplying a hazard ratio for a common outcome, set this to "hr"; if you are supplying an odds ratio for a common outcome, set this to "or"; if you are supplying a risk ratio or your outcome is rare, set this to "none" (default). |
Data frame.
## to estimate the relationship between an unmeasured confounder and outcome ## needed to tip analysis tip(1.2, exposure_confounder_effect = -2) ## to estimate the number of unmeasured confounders specified needed to tip ## the analysis tip(1.2, exposure_confounder_effect = -2, confounder_outcome_effect = .99) ## Example with broom if (requireNamespace("broom", quietly = TRUE) && requireNamespace("dplyr", quietly = TRUE)) { glm(am ~ mpg, data = mtcars, family = "binomial") %>% broom::tidy(conf.int = TRUE, exponentiate = TRUE) %>% dplyr::filter(term == "mpg") %>% dplyr::pull(conf.low) %>% tip(confounder_outcome_effect = 2.5) }
## to estimate the relationship between an unmeasured confounder and outcome ## needed to tip analysis tip(1.2, exposure_confounder_effect = -2) ## to estimate the number of unmeasured confounders specified needed to tip ## the analysis tip(1.2, exposure_confounder_effect = -2, confounder_outcome_effect = .99) ## Example with broom if (requireNamespace("broom", quietly = TRUE) && requireNamespace("dplyr", quietly = TRUE)) { glm(am ~ mpg, data = mtcars, family = "binomial") %>% broom::tidy(conf.int = TRUE, exponentiate = TRUE) %>% dplyr::filter(term == "mpg") %>% dplyr::pull(conf.low) %>% tip(confounder_outcome_effect = 2.5) }
choose one of the following, and the other will be estimated:
exposure_confounder_effect
confounder_outcome_effect
tip_coef( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE) ) tip_coef_with_continuous( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE) )
tip_coef( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE) ) tip_coef_with_continuous( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE) )
effect_observed |
Numeric. Observed exposure - outcome effect from a regression model. This can be the beta coefficient, the lower confidence bound of the beta coefficient, or the upper confidence bound of the beta coefficient. |
exposure_confounder_effect |
Numeric. Estimated scaled mean difference between the unmeasured confounder in the exposed population and unexposed population |
confounder_outcome_effect |
Numeric positive value. Estimated relationship between the unmeasured confounder and the outcome |
verbose |
Logical. Indicates whether to print informative message.
Default: |
Data frame.
## to estimate the relationship between an unmeasured confounder and outcome ## needed to tip analysis tip_coef(1.2, exposure_confounder_effect = -2) ## to estimate the number of unmeasured confounders specified needed to tip ## the analysis tip_coef(1.2, exposure_confounder_effect = -2, confounder_outcome_effect = -0.05) ## Example with broom if (requireNamespace("broom", quietly = TRUE) && requireNamespace("dplyr", quietly = TRUE)) { lm(wt ~ mpg, data = mtcars) %>% broom::tidy(conf.int = TRUE) %>% dplyr::filter(term == "mpg") %>% dplyr::pull(conf.low) %>% tip_coef(confounder_outcome_effect = 2.5) }
## to estimate the relationship between an unmeasured confounder and outcome ## needed to tip analysis tip_coef(1.2, exposure_confounder_effect = -2) ## to estimate the number of unmeasured confounders specified needed to tip ## the analysis tip_coef(1.2, exposure_confounder_effect = -2, confounder_outcome_effect = -0.05) ## Example with broom if (requireNamespace("broom", quietly = TRUE) && requireNamespace("dplyr", quietly = TRUE)) { lm(wt ~ mpg, data = mtcars) %>% broom::tidy(conf.int = TRUE) %>% dplyr::filter(term == "mpg") %>% dplyr::pull(conf.low) %>% tip_coef(confounder_outcome_effect = 2.5) }
Choose one of the following, and the other will be estimated:
confounder_exposure_r2
confounder_outcome_r2
tip_coef_with_r2( effect_observed, se, df, confounder_exposure_r2 = NULL, confounder_outcome_r2 = NULL, verbose = getOption("tipr.verbose", TRUE), alpha = 0.05, tip_bound = FALSE, ... )
tip_coef_with_r2( effect_observed, se, df, confounder_exposure_r2 = NULL, confounder_outcome_r2 = NULL, verbose = getOption("tipr.verbose", TRUE), alpha = 0.05, tip_bound = FALSE, ... )
effect_observed |
Numeric. Observed exposure - outcome effect from a regression model. This is the point estimate (beta coefficient) |
se |
Numeric. Standard error of the |
df |
Numeric positive value. Residual degrees of freedom for the model used to estimate the observed exposure - outcome effect. This is the total number of observations minus the number of parameters estimated in your model. Often for models estimated with an intercept this is N - k - 1 where k is the number of predictors in the model. |
confounder_exposure_r2 |
Numeric value between 0 and 1. The assumed partial R2 of the unobserved confounder with the exposure given the measured covariates. |
confounder_outcome_r2 |
Numeric value between 0 and 1. The assumed partial R2 of the unobserved confounder with the outcome given the exposure and the measured covariates. |
verbose |
Logical. Indicates whether to print informative message.
Default: |
alpha |
Significance level. Default = |
tip_bound |
Do you want to tip at the bound? Default = |
... |
Optional arguments passed to the |
A data frame.
tip_coef_with_r2(0.5, 0.1, 102, 0.5)
tip_coef_with_r2(0.5, 0.1, 102, 0.5)
choose one of the following, and the other will be estimated:
exposure_confounder_effect
confounder_outcome_effect
tip_hr( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), hr_correction = FALSE ) tip_hr_with_continuous( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), hr_correction = FALSE )
tip_hr( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), hr_correction = FALSE ) tip_hr_with_continuous( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), hr_correction = FALSE )
effect_observed |
Numeric positive value. Observed exposure - outcome hazard ratio. This can be the point estimate, lower confidence bound, or upper confidence bound. |
exposure_confounder_effect |
Numeric. Estimated difference in scaled means between the unmeasured confounder in the exposed population and unexposed population |
confounder_outcome_effect |
Numeric positive value. Estimated relationship between the unmeasured confounder and the outcome |
verbose |
Logical. Indicates whether to print informative message.
Default: |
hr_correction |
Logical. Indicates whether to use a correction factor.
The methods used for this function are based on risk ratios. For rare
outcomes, a hazard ratio approximates a risk ratio. For common outcomes,
a correction factor is needed. If you have a common outcome (>15%),
set this to |
Data frame.
## to estimate the relationship between an unmeasured confounder and outcome ## needed to tip analysis tip_hr(1.2, exposure_confounder_effect = -2) ## to estimate the number of unmeasured confounders specified needed to tip ## the analysis tip_hr(1.2, exposure_confounder_effect = -2, confounder_outcome_effect = .99)
## to estimate the relationship between an unmeasured confounder and outcome ## needed to tip analysis tip_hr(1.2, exposure_confounder_effect = -2) ## to estimate the number of unmeasured confounders specified needed to tip ## the analysis tip_hr(1.2, exposure_confounder_effect = -2, confounder_outcome_effect = .99)
Choose two of the following three to specify, and the third will be estimated:
exposed_confounder_prev
unexposed_confounder_prev
confounder_outcome_effect
Alternatively, specify all three and the function will return the number of unmeasured confounders specified needed to tip the analysis.
tip_hr_with_binary( effect_observed, exposed_confounder_prev = NULL, unexposed_confounder_prev = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), hr_correction = FALSE )
tip_hr_with_binary( effect_observed, exposed_confounder_prev = NULL, unexposed_confounder_prev = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), hr_correction = FALSE )
effect_observed |
Numeric positive value. Observed exposure - outcome hazard ratio. This can be the point estimate, lower confidence bound, or upper confidence bound. |
exposed_confounder_prev |
Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the exposed population |
unexposed_confounder_prev |
Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the unexposed population |
confounder_outcome_effect |
Numeric positive value. Estimated relationship between the unmeasured confounder and the outcome |
verbose |
Logical. Indicates whether to print informative message.
Default: |
hr_correction |
Logical. Indicates whether to use a correction factor.
The methods used for this function are based on risk ratios. For rare
outcomes, a hazard ratio approximates a risk ratio. For common outcomes,
a correction factor is needed. If you have a common outcome (>15%),
set this to |
Data frame.
tip_hr_with_binary(0.9, 0.9, 0.1)
tip_hr_with_binary(0.9, 0.9, 0.1)
choose one of the following, and the other will be estimated:
exposure_confounder_effect
confounder_outcome_effect
tip_or( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), or_correction = FALSE ) tip_or_with_continuous( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), or_correction = FALSE )
tip_or( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), or_correction = FALSE ) tip_or_with_continuous( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), or_correction = FALSE )
effect_observed |
Numeric positive value. Observed exposure - outcome odds ratio. This can be the point estimate, lower confidence bound, or upper confidence bound. |
exposure_confounder_effect |
Numeric. Estimated difference in scaled means between the unmeasured confounder in the exposed population and unexposed population |
confounder_outcome_effect |
Numeric positive value. Estimated relationship between the unmeasured confounder and the outcome |
verbose |
Logical. Indicates whether to print informative message.
Default: |
or_correction |
Logical. Indicates whether to use a correction factor.
The methods used for this function are based on risk ratios. For rare
outcomes, an odds ratio approximates a risk ratio. For common outcomes,
a correction factor is needed. If you have a common outcome (>15%),
set this to |
Data frame.
## to estimate the relationship between an unmeasured confounder and outcome ## needed to tip analysis tip_or(1.2, exposure_confounder_effect = -2) ## to estimate the number of unmeasured confounders specified needed to tip ## the analysis tip_or(1.2, exposure_confounder_effect = -2, confounder_outcome_effect = .99) ## Example with broom if (requireNamespace("broom", quietly = TRUE) && requireNamespace("dplyr", quietly = TRUE)) { glm(am ~ mpg, data = mtcars, family = "binomial") %>% broom::tidy(conf.int = TRUE, exponentiate = TRUE) %>% dplyr::filter(term == "mpg") %>% dplyr::pull(conf.low) %>% tip_or(confounder_outcome_effect = 2.5, or_correction = TRUE) }
## to estimate the relationship between an unmeasured confounder and outcome ## needed to tip analysis tip_or(1.2, exposure_confounder_effect = -2) ## to estimate the number of unmeasured confounders specified needed to tip ## the analysis tip_or(1.2, exposure_confounder_effect = -2, confounder_outcome_effect = .99) ## Example with broom if (requireNamespace("broom", quietly = TRUE) && requireNamespace("dplyr", quietly = TRUE)) { glm(am ~ mpg, data = mtcars, family = "binomial") %>% broom::tidy(conf.int = TRUE, exponentiate = TRUE) %>% dplyr::filter(term == "mpg") %>% dplyr::pull(conf.low) %>% tip_or(confounder_outcome_effect = 2.5, or_correction = TRUE) }
Choose two of the following three to specify, and the third will be estimated:
exposed_confounder_prev
unexposed_confounder_prev
confounder_outcome_effect
Alternatively, specify all three and the function will return the number of unmeasured confounders specified needed to tip the analysis.
tip_or_with_binary( effect_observed, exposed_confounder_prev = NULL, unexposed_confounder_prev = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), or_correction = FALSE )
tip_or_with_binary( effect_observed, exposed_confounder_prev = NULL, unexposed_confounder_prev = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), or_correction = FALSE )
effect_observed |
Numeric positive value. Observed exposure - outcome odds ratio. This can be the point estimate, lower confidence bound, or upper confidence bound. |
exposed_confounder_prev |
Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the exposed population |
unexposed_confounder_prev |
Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the unexposed population |
confounder_outcome_effect |
Numeric positive value. Estimated relationship between the unmeasured confounder and the outcome |
verbose |
Logical. Indicates whether to print informative message.
Default: |
or_correction |
Logical. Indicates whether to use a correction factor.
The methods used for this function are based on risk ratios. For rare
outcomes, an odds ratio approximates a risk ratio. For common outcomes,
a correction factor is needed. If you have a common outcome (>15%),
set this to |
Data frame.
tip_or_with_binary(0.9, 0.9, 0.1)
tip_or_with_binary(0.9, 0.9, 0.1)
choose one of the following, and the other will be estimated:
exposure_confounder_effect
confounder_outcome_effect
tip_rr( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE) ) tip_rr_with_continuous( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE) )
tip_rr( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE) ) tip_rr_with_continuous( effect_observed, exposure_confounder_effect = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE) )
effect_observed |
Numeric positive value. Observed exposure - outcome risk ratio. This can be the point estimate, lower confidence bound, or upper confidence bound. |
exposure_confounder_effect |
Numeric. Estimated difference in scaled means between the unmeasured confounder in the exposed population and unexposed population |
confounder_outcome_effect |
Numeric positive value. Estimated relationship between the unmeasured confounder and the outcome |
verbose |
Logical. Indicates whether to print informative message.
Default: |
Data frame.
## to estimate the relationship between an unmeasured confounder and outcome ## needed to tip analysis tip_rr(1.2, exposure_confounder_effect = -2) ## to estimate the number of unmeasured confounders specified needed to tip ## the analysis tip_rr(1.2, exposure_confounder_effect = -2, confounder_outcome_effect = .99)
## to estimate the relationship between an unmeasured confounder and outcome ## needed to tip analysis tip_rr(1.2, exposure_confounder_effect = -2) ## to estimate the number of unmeasured confounders specified needed to tip ## the analysis tip_rr(1.2, exposure_confounder_effect = -2, confounder_outcome_effect = .99)
Choose two of the following three to specify, and the third will be estimated:
exposed_confounder_prev
unexposed_confounder_prev
confounder_outcome_effect
Alternatively, specify all three and the function will return the number of unmeasured confounders specified needed to tip the analysis.
tip_rr_with_binary( effect_observed, exposed_confounder_prev = NULL, unexposed_confounder_prev = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE) )
tip_rr_with_binary( effect_observed, exposed_confounder_prev = NULL, unexposed_confounder_prev = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE) )
effect_observed |
Numeric positive value. Observed exposure - outcome risk ratio. This can be the point estimate, lower confidence bound, or upper confidence bound. |
exposed_confounder_prev |
Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the exposed population |
unexposed_confounder_prev |
Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the unexposed population |
confounder_outcome_effect |
Numeric positive value. Estimated relationship between the unmeasured confounder and the outcome |
verbose |
Logical. Indicates whether to print informative message.
Default: |
Choose two of the following three to specify, and the third will be estimated:
exposed_confounder_prev
unexposed_confounder_prev
confounder_outcome_effect
Alternatively, specify all three and the function will return the number of unmeasured confounders specified needed to tip the analysis.
tip_with_binary( effect_observed, exposed_confounder_prev = NULL, unexposed_confounder_prev = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), correction_factor = "none" ) tip_b( effect_observed, exposed_confounder_prev = NULL, unexposed_confounder_prev = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), correction_factor = "none" )
tip_with_binary( effect_observed, exposed_confounder_prev = NULL, unexposed_confounder_prev = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), correction_factor = "none" ) tip_b( effect_observed, exposed_confounder_prev = NULL, unexposed_confounder_prev = NULL, confounder_outcome_effect = NULL, verbose = getOption("tipr.verbose", TRUE), correction_factor = "none" )
effect_observed |
Numeric positive value. Observed exposure - outcome effect (assumed to be the exponentiated coefficient, so a risk ratio, odds ratio, or hazard ratio). This can be the point estimate, lower confidence bound, or upper confidence bound. |
exposed_confounder_prev |
Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the exposed population |
unexposed_confounder_prev |
Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the unexposed population |
confounder_outcome_effect |
Numeric positive value. Estimated relationship between the unmeasured confounder and the outcome |
verbose |
Logical. Indicates whether to print informative message.
Default: |
correction_factor |
Character string. Options are "none", "hr", "or". For common outcomes (>15%), the odds ratio or hazard ratio is not a good estimate for the risk ratio. In these cases, we can apply a correction factor. If you are supplying a hazard ratio for a common outcome, set this to "hr"; if you are supplying an odds ratio for a common outcome, set this to "or"; if you are supplying a risk ratio or your outcome is rare, set this to "none" (default). |
tip_b()
is an alias for tip_with_binary()
.
## to estimate the relationship between an unmeasured confounder and outcome ## needed to tip analysis tip_with_binary(1.2, exposed_confounder_prev = 0.5, unexposed_confounder_prev = 0) ## to estimate the number of unmeasured confounders specified needed to tip ## the analysis tip_with_binary(1.2, exposed_confounder_prev = 0.5, unexposed_confounder_prev = 0, confounder_outcome_effect = 1.1) ## Example with broom if (requireNamespace("broom", quietly = TRUE) && requireNamespace("dplyr", quietly = TRUE)) { glm(am ~ mpg, data = mtcars, family = "binomial") %>% broom::tidy(conf.int = TRUE, exponentiate = TRUE) %>% dplyr::filter(term == "mpg") %>% dplyr::pull(conf.low) %>% tip_with_binary(exposed_confounder_prev = 1, confounder_outcome_effect = 1.15) }
## to estimate the relationship between an unmeasured confounder and outcome ## needed to tip analysis tip_with_binary(1.2, exposed_confounder_prev = 0.5, unexposed_confounder_prev = 0) ## to estimate the number of unmeasured confounders specified needed to tip ## the analysis tip_with_binary(1.2, exposed_confounder_prev = 0.5, unexposed_confounder_prev = 0, confounder_outcome_effect = 1.1) ## Example with broom if (requireNamespace("broom", quietly = TRUE) && requireNamespace("dplyr", quietly = TRUE)) { glm(am ~ mpg, data = mtcars, family = "binomial") %>% broom::tidy(conf.int = TRUE, exponentiate = TRUE) %>% dplyr::filter(term == "mpg") %>% dplyr::pull(conf.low) %>% tip_with_binary(exposed_confounder_prev = 1, confounder_outcome_effect = 1.15) }