Skip to content

Commit 518615d

Browse files
committed
change tip_lm name to tip_coef
1 parent e1ccb24 commit 518615d

File tree

4 files changed

+35
-55
lines changed

4 files changed

+35
-55
lines changed

NAMESPACE

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ export(r_value)
2424
export(tip)
2525
export(tip_b)
2626
export(tip_c)
27+
export(tip_coef)
28+
export(tip_coef_with_continuous)
2729
export(tip_coef_with_r2)
2830
export(tip_hr)
2931
export(tip_hr_with_binary)
3032
export(tip_hr_with_continuous)
31-
export(tip_lm)
3233
export(tip_or)
3334
export(tip_or_with_binary)
3435
export(tip_or_with_continuous)

NEWS.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# tipr 0.4.1
22

33
* Add additional functions that specify `*_with_continuous()` (long form of, the function names, the default unmeasured confounder is Normally distributed)
4+
* Change `tip_lm()` to `tip_coef()`.
45

56
# tipr 0.4.0
67

R/tip_lm.R renamed to R/tip_coef.R

+18-34
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' Tip a linear model result with a continuous confounder.
1+
#' Tip a linear model coefficient with a continuous confounder.
22
#'
33
#' choose one of the following, and the other will be estimated:
44
#' * `smd`
@@ -14,24 +14,17 @@
1414
#' between the unmeasured confounder and the outcome
1515
#' @param verbose Logical. Indicates whether to print informative message.
1616
#' Default: `TRUE`
17-
#' @param correction_factor Character string. Options are "none", "hr", "or".
18-
#' For common outcomes (>15%), the odds ratio or hazard ratio is not a good
19-
#' estimate for the relative risk. In these cases, we can apply a correction
20-
#' factor. If you are supplying a hazard ratio for a common outcome, set
21-
#' this to "hr"; if you are supplying an odds ratio for a common outcome, set
22-
#' this to "or"; if you are supplying a risk ratio or your outcome is rare,
23-
#' set this to "none" (default).
2417
#'
2518
#' @return Data frame.
2619
#'
2720
#' @examples
2821
#' ## to estimate the association between an unmeasured confounder and outcome
2922
#' ## needed to tip analysis
30-
#' tip_lm(1.2, smd = -2)
23+
#' tip_coef(1.2, smd = -2)
3124
#'
3225
#' ## to estimate the number of unmeasured confounders specified needed to tip
3326
#' ## the analysis
34-
#' tip_lm(1.2, smd = -2, outcome_association = -0.05)
27+
#' tip_coef(1.2, smd = -2, outcome_association = -0.05)
3528
#'
3629
#' ## Example with broom
3730
#' if (requireNamespace("broom", quietly = TRUE) &&
@@ -40,38 +33,25 @@
4033
#' broom::tidy(conf.int = TRUE) %>%
4134
#' dplyr::filter(term == "mpg") %>%
4235
#' dplyr::pull(conf.low) %>%
43-
#' tip_lm(outcome_association = 2.5)
36+
#' tip_coef(outcome_association = 2.5)
4437
#'}
4538
#' @export
46-
tip_lm <- function(effect, smd = NULL, outcome_association = NULL, verbose = TRUE, correction_factor = "none") {
39+
tip_coef <- function(effect, smd = NULL, outcome_association = NULL, verbose = TRUE) {
4740

4841
o <- purrr::map(
4942
effect,
50-
~ tip_lm_one(.x,
43+
~ tip_coef_one(.x,
5144
smd = smd,
5245
outcome_association = outcome_association,
53-
verbose = verbose,
54-
correction_factor = correction_factor
46+
verbose = verbose
5547
)
5648
)
5749
do.call(rbind, o)
5850
}
5951

60-
tip_lm_one <- function(b, smd, outcome_association, verbose, correction_factor) {
52+
tip_coef_one <- function(b, smd, outcome_association, verbose) {
6153

6254
n_unmeasured_confounders <- 1
63-
correction <- ""
64-
if (correction_factor == "hr") {
65-
b <- hr_transform(b)
66-
outcome_association <- hr_transform(outcome_association)
67-
correction <- 'You opted to use the hazard ratio correction to convert your hazard ratios to approximate risk ratios.\nThis is a good idea if the outcome is common (>15%).'
68-
}
69-
70-
if (correction_factor == "or") {
71-
b <- or_transform(b)
72-
outcome_association <- or_transform(outcome_association)
73-
correction <- 'You opted to use the odds ratio correction to convert your odds ratios to approximate risk ratios.\nThis is a good idea if the outcome is common (>15%).'
74-
}
7555

7656
if (is.null(outcome_association)) {
7757
outcome_association <- b / smd
@@ -130,7 +110,7 @@ tip_lm_one <- function(b, smd, outcome_association, verbose, correction_factor)
130110
"unmeasured confounder\n in the exposed population and ",
131111
"unexposed population: {round(o_notip$smd, 2)}",
132112
"\n * estimated association between the unmeasured confounder and the ",
133-
"outcome: {round(o_notip$outcome_association, 2)}\n\n{correction}"
113+
"outcome: {round(o_notip$outcome_association, 2)}\n\n"
134114
)
135115
} else if (any(o$n_unmeasured_confounders == 0)) {
136116
o_notip <- o[o$n_unmeasured_confounders == 0,]
@@ -142,7 +122,7 @@ tip_lm_one <- function(b, smd, outcome_association, verbose, correction_factor)
142122
"unmeasured confounder\n in the exposed population and ",
143123
"unexposed population: {round(o_notip$smd, 2)}",
144124
"\n * estimated association between the unmeasured confounder and the ",
145-
"outcome: {round(o_notip$outcome_association, 2)}\n\n{correction}"
125+
"outcome: {round(o_notip$outcome_association, 2)}\n\n"
146126
)
147127

148128
o_tip <- o[o$n_unmeasured_confounders != 0,]
@@ -155,7 +135,7 @@ tip_lm_one <- function(b, smd, outcome_association, verbose, correction_factor)
155135
"unmeasured confounder\n in the exposed population and ",
156136
"unexposed population: {round(o_tip$smd, 2)}",
157137
"\n * estimated association between the unmeasured confounder and the ",
158-
"outcome: {round(o_tip$outcome_association, 2)}\n\n{correction}"
138+
"outcome: {round(o_tip$outcome_association, 2)}\n\n"
159139
)
160140
} else {
161141
message_glue(
@@ -167,16 +147,20 @@ tip_lm_one <- function(b, smd, outcome_association, verbose, correction_factor)
167147
"unmeasured confounder\n in the exposed population and ",
168148
"unexposed population: {round(o$smd, 2)}",
169149
"\n * estimated association between the unmeasured confounder and the ",
170-
"outcome: {round(o$outcome_association, 2)}\n\n{correction}"
150+
"outcome: {round(o$outcome_association, 2)}\n\n"
171151
)
172152
}
173153
}
174154
o
175155
}
176156

177-
#' @rdname tip_lm
157+
#' @rdname tip_coef
178158
#' @export
179159
lm_tip <- function(effect, smd, outcome_association, verbose = TRUE) {
180160
.Deprecated("tip_lm")
181-
tip_lm(effect, smd, outcome_association, verbose)
161+
tip_coef(effect, smd, outcome_association, verbose)
182162
}
163+
164+
#' @rdname tip_coef
165+
#' @export
166+
tip_coef_with_continuous <- tip_coef

man/tip_lm.Rd renamed to man/tip_coef.Rd

+14-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)