Learn R Programming

tipr (version 0.3.0)

tip_with_binary: Tip a result with a binary confounder.

Description

Choose two of the following three to specify, and the third will be estimated:

  • exposed_p

  • unexposed_p

  • outcome_association

Alternatively, specify all three and the function will return the number of unmeasured confounders specified needed to tip the analysis.

Usage

tip_with_binary(
  d,
  exposed_p = NULL,
  unexposed_p = NULL,
  outcome_association = NULL,
  verbose = TRUE,
  lb_name = "conf.low",
  ub_name = "conf.high"
)

tip_b( d, exposed_p = NULL, unexposed_p = NULL, outcome_association = NULL, verbose = TRUE, lb_name = "conf.low", ub_name = "conf.high" )

Arguments

d

Data frame. A data frame with the observed effect(s). This should have at least two columns with the lower and upper confidence bounds. These columns are assumed to be called conf.low and conf.high. If this is not the case, the names can be changed using the lb_name and ub_name parameters.

exposed_p

Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the exposed population

unexposed_p

Numeric between 0 and 1. Estimated prevalence of the unmeasured confounder in the unexposed population

outcome_association

Numeric positive value. estimated association between the unmeasured confounder and the outcome

verbose

Logical. Indicates whether to print informative message. Default: TRUE

lb_name

Character. Column name of d that holds the lower confidence bound. Default: conf.low based on broom defaults.

ub_name

Character. Column name of d that holds the upper confidence bound. Default: conf.high based on broom defaults.

Details

tip_b() is an alias for tip_with_binary().

Examples

Run this code
# NOT RUN {
d <- data.frame(conf.low = 1.2, conf.high = 1.5)
## to estimate the association between an unmeasured confounder and outcome
## needed to tip analysis
tip_with_binary(d, exposed_p = 0.5, unexposed_p = 0)

## to estimate the number of unmeasured confounders specified needed to tip
## the analysis
tip_with_binary(d, exposed_p = 0.5, unexposed_p = 0, outcome_association = 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") %>%
   tip_with_binary(exposed_p = 1, outcome_association = 1.15)
}
# }

Run the code above in your browser using DataLab