Description Usage Arguments Value Note Examples
View source: R/bootstrap_propen.R
Calculate bootstrap CI for treatment effect estimate
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | bootstrap_propen(
data.in,
indicator.var = "indicator",
formula,
indicator.next = NULL,
seed = 100,
class.of.int,
estimate.res,
n.boot = 1000,
method = "ipw",
wild.boot = FALSE,
tte = "AVAL",
event = "event",
trt = "trt",
response = NULL,
caliper = NULL,
pairs = NULL,
hr.ratio.ref = NULL,
ref.denom = TRUE,
model = "plain",
max.num.run = 5000,
non.converge.check = FALSE,
multinom.maxit = 100,
non.converge.check.thresh = 1
)
|
data.in |
( |
indicator.var |
( |
formula |
( |
indicator.next |
( |
seed |
seed |
class.of.int |
( |
estimate.res |
result object from ipw_strata() or ps_match_strata() |
n.boot |
number of bootstraps to run; note only runs without warning/error msg will be considered when calculating bootstrap CI; so it is possible more that n.boot runs are performed (but capped by max.num.run) |
method |
"ipw" or "ps". If "ipw", ipw_strata() will be used. If "ps", ps_match_strata() will be used. |
wild.boot |
whether wild bootstrap should be used. If so, weights will be generated using rexp(1) |
tte |
( |
event |
( |
trt |
( |
response |
( |
caliper |
A scalar or vector denoting the caliper(s) which
should be used when matching. A caliper is the distance which is
acceptable for any match. Observations which are outside of the
caliper are dropped. If a scalar caliper is provided, this caliper is
used for all covariates in |
pairs |
pairs of interest when calculating ratio of HR (delta of delta for OR). this should be a matrix whose rows are names of strata, 1st column indicates the stratum to be used as numerator (HR or ORR diff); 2nd column indicates denominator. If pairs is NULL, ratio of HR (difference of OR difference) will not be calculated. |
hr.ratio.ref |
no longer to be used, please use pairs instead |
ref.denom |
no longer to be used, please use pairs instead |
model |
(
|
max.num.run |
max number of bootstraps to run (include both valid and not valid runs) |
non.converge.check |
whether to output number of time each level of each categorical variable for each stratum specified in indicator having N<non.converge.check.thresh when non-convergence occurs |
multinom.maxit |
see parameter |
non.converge.check.thresh |
see above |
return a list
containing the following components:
boot.out.est a matrix
with rows as estimates such as Coefficient and Variance in strata
and columns as summary statistics such as Mean and Median of the estimates.
est.ci.mat a matrix
with rows as strata and columns as Estimate and Bootstrap CIs.
eff.comp.ci.mat a matrix
with rows as strata comparisons and columns as Estimate and Bootstrp CIs.
conv.est a logical
vector to indicate whether model in each bootstrap converges.
error.est numeric
to indicate the total number of models in bootstrap which gives errors.
boot.results a matrix
with rows as each bootstrap and columns as model results such as Coefficient in strata.
glm.warn.est a logical
vector to indicate whether glm model gives warning in each bootstrap.
num.valid.boots numeric
to indicate the total number of valid bootstraps.
num.total.boots numeric
for the total number of bootstrap runs.
warning.msg a list
to capture warning messages from models.
error.msg a list
to capture error messages from models.
non.converge.dat a matrix
with rows as each level of each categorical variable for each stratum specified in
indicator having N less than non.converge.check.thresh
and columns as treatment groups
only estimates from runs without error or warning will be considered when calculating bootstrap CI. If none of the bootstrap runs is error/warning free, CI of est.ci.mat will be NA
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | library(dplyr)
clinical_1 <- clinical %>% mutate(
indicator = case_when(
STRATUM == "strata_1" ~ 0,
STRATUM == "strata_2" ~ 1,
is.na(STRATUM) & ARM == "experimental" ~ 1,
TRUE ~ -1
),
ARM = factor(ARM, levels = c("control","experimental")),
BNLR = case_when(
is.na(BNLR) ~ median(BNLR, na.rm = TRUE),
TRUE ~ BNLR
)
)
# ipw: default model
ipw_res <- ipw_strata(
data.in = clinical_1, formula = indicator ~ BECOG + SEX + BNLR,
indicator.var = "indicator", tte = "OS_MONTH", event = "OS_EVENT", trt = "ARM",
class.of.int = list("strata_1" = 1, "strata_2" = 0)
)
boot_ipw <- bootstrap_propen(
data.in = clinical_1, formula = indicator ~ BECOG + SEX + BNLR,
indicator.var = "indicator", tte = "OS_MONTH", event = "OS_EVENT", trt = "ARM",
class.of.int = list("strata_1" = 1, "strata_2" = 0),
estimate.res = ipw_res, method = "ipw", n.boot = 5
)
boot_ipw$est.ci.mat
boot_ipw$boot.out.est
# ps: DWC model
clinical_2 <- clinical %>% mutate(
indicator = case_when(
STRATUM == "strata_1" ~ 0,
STRATUM == "strata_2" ~ 1,
is.na(STRATUM) & ARM == "experimental" ~ 2,
TRUE ~ -1
),
ARM = factor(ARM, levels = c("control","experimental")),
BNLR = case_when(
is.na(BNLR) ~ median(BNLR, na.rm = TRUE),
TRUE ~ BNLR
)
)
ps_res <- ps_match_strata(
data.in = clinical_2, formula = indicator ~ BECOG + SEX + BNLR, model = "dwc",
indicator.var = "indicator", tte = "OS_MONTH", event = "OS_EVENT", trt = "ARM",
class.of.int = list("strata_1" = 0, "strata_2" = 1, "missing" = 2)
)
boot_ps <- bootstrap_propen(
data.in = clinical_2, formula = indicator ~ BECOG + SEX + BNLR, model = "dwc",
indicator.var = "indicator", tte = "OS_MONTH", event = "OS_EVENT", trt = "ARM",
class.of.int = list("strata_1" = 0, "strata_2" = 1, "missing" = 2),
estimate.res = ps_res, method = "ps", n.boot = 5
)
boot_ps$est.ci.mat
boot_ps$boot.out.est
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.