Learn R Programming

tipr (version 0.3.0)

lm_tip: Tip a linear model result with a continuous confounder.

Description

choose one of the following, and the other will be estimated:

  • smd

  • outcome_association

Usage

lm_tip(
  d,
  smd = 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.

smd

Numeric. Estimated scaled mean difference between the unmeasured confounder in the exposed population and 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.

Value

Data frame.

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
lm_tip(d, smd = -2)

## to estimate the number of unmeasured confounders specified needed to tip
## the analysis
lm_tip(d, smd = -2, outcome_association = -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") %>%
   lm_tip(outcome_association = 2.5)
}
# }

Run the code above in your browser using DataLab