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

Description Usage Arguments Value Examples

View source: R/lm_tip.R

Description

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

Usage

1
2
3
4
5
6
7
8
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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)
}

tipr documentation built on Sept. 10, 2021, 9:06 a.m.