|
6 | 6 | #' Methods taken from |
7 | 7 | #' \insertCite{RemiroAzocar2022}{outstandR}. |
8 | 8 | #' |
9 | | -#' @param ipd_trial Individual-level patient data. Suppose between studies _A_ and _C_. |
10 | | -#' @param ald_trial Aggregate-level data. Suppose between studies _B_ and _C_. |
| 9 | +#' @param ipd_trial Individual-level patient data. For example, suppose between studies _A_ and _C_. |
| 10 | +#' In a long format and must contain a treatment column and outcome column consistent with the formula object. |
| 11 | +#' The labels in the treatment are used internally so there must be a common treatment with the aggregate-level data trial. |
| 12 | +#' @param ald_trial Aggregate-level data. For example, suppose between studies _B_ and _C_. The column names take the form |
| 13 | +#' - `mean.X*`: mean patient measurement |
| 14 | +#' - `sd.X*`: standard deviation of patient measurement |
| 15 | +#' - `y.*.sum`: total number of events |
| 16 | +#' - `y.*.bar`: proportion of events |
| 17 | +#' - `N.*`: total number of individuals |
11 | 18 | #' @param strategy Computation strategy function. These can be |
12 | 19 | #' `strategy_maic()`, `strategy_stc()`, `strategy_gcomp_ml()` and `strategy_gcomp_stan()` |
| 20 | +#' @param ref_trt Reference / common / anchoring treatment name; default "C" |
13 | 21 | #' @param CI Confidence interval; between 0,1 |
14 | 22 | #' @param scale Relative treatment effect scale. If `NULL`, the scale is automatically determined from the model. |
15 | 23 | #' @param ... Additional arguments |
|
27 | 35 | #' data(AC_IPD) # AC patient-level data |
28 | 36 | #' data(BC_ALD) # BC aggregate-level data |
29 | 37 | #' |
| 38 | +#' # linear formula |
30 | 39 | #' lin_form <- as.formula("y ~ X3 + X4 + trt*X1 + trt*X2") |
31 | 40 | #' |
32 | 41 | #' # matching-adjusted indirect comparison |
33 | | -#' outstandR_maic <- outstandR(AC_IPD, BC_ALD, strategy = strategy_maic(formula = lin_form)) |
| 42 | +#' outstandR_maic <- outstandR(AC_IPD, BC_ALD, |
| 43 | +#' strategy = strategy_maic(formula = lin_form)) |
34 | 44 | #' |
35 | 45 | #' # simulated treatment comparison |
36 | | -#' outstandR_stc <- outstandR(AC_IPD, BC_ALD, strategy = strategy_stc(lin_form)) |
| 46 | +#' outstandR_stc <- outstandR(AC_IPD, BC_ALD, |
| 47 | +#' strategy = strategy_stc(lin_form)) |
37 | 48 | #' |
38 | 49 | #' # G-computation with maximum likelihood |
39 | | -#' # outstandR_gcomp_ml <- outstandR(AC_IPD, BC_ALD, strategy = strategy_gcomp_ml(lin_form)) |
| 50 | +#' # outstandR_gcomp_ml <- outstandR(AC_IPD, BC_ALD, |
| 51 | +#' strategy = strategy_gcomp_ml(lin_form)) |
40 | 52 | #' |
41 | 53 | #' # G-computation with Bayesian inference |
42 | | -#' outstandR_gcomp_stan <- outstandR(AC_IPD, BC_ALD, strategy = strategy_gcomp_stan(lin_form)) |
| 54 | +#' outstandR_gcomp_stan <- outstandR(AC_IPD, BC_ALD, |
| 55 | +#' strategy = strategy_gcomp_stan(lin_form)) |
43 | 56 | #' |
44 | 57 | #' # Multiple imputation marginalization |
45 | | -#' outstandR_gcomp_stan <- outstandR(AC_IPD, BC_ALD, strategy = strategy_mim(lin_form)) |
| 58 | +#' outstandR_mim <- outstandR(AC_IPD, BC_ALD, |
| 59 | +#' strategy = strategy_mim(lin_form)) |
46 | 60 | #' |
47 | | -outstandR <- function(ipd_trial, ald_trial, ref_trt = "C", |
48 | | - strategy, CI = 0.95, scale = NULL, ...) { |
| 61 | +outstandR <- function(ipd_trial, ald_trial, strategy, |
| 62 | + ref_trt = "C", |
| 63 | + CI = 0.95, scale = NULL, ...) { |
49 | 64 |
|
50 | 65 | validate_outstandr(ipd_trial, ald_trial, strategy, CI, scale) |
51 | 66 |
|
52 | 67 | ipd <- prep_ipd(strategy$formula, ipd_trial) |
53 | 68 | ald <- prep_ald(strategy$formula, ald_trial, trt_var = strategy$trt_var) |
54 | 69 |
|
55 | | - ipd_trts <- get_ipd_trts(ipd, ref_trt) |
56 | | - ald_trts <- get_ald_trts(ald, ref_trt) |
| 70 | + # treatment names for each study |
| 71 | + |
| 72 | + ipd_comp <- get_ipd_comparator(ipd, ref_trt, strategy$trt_var) |
| 73 | + ald_comp <- get_ald_comparator(ald, ref_trt) |
| 74 | + |
| 75 | + ipd_trts <- list(ipd_comp, ref_trt) |
| 76 | + ald_trts <- list(ald_comp, ref_trt) |
57 | 77 |
|
58 | 78 | if (is.null(scale)) scale <- get_treatment_effect(strategy$family$link) |
59 | 79 |
|
60 | | - ipd_stats <- calc_IPD_stats(strategy, ipd = ipd, ald = ald, scale, ...) |
61 | | - ald_stats <- calc_ALD_stats(strategy, ald = ald, treatments = ald_trts, scale = scale) |
| 80 | + ipd_stats <- calc_IPD_stats(strategy, |
| 81 | + ipd = ipd, ald = ald, |
| 82 | + scale, ...) |
| 83 | + |
| 84 | + ald_stats <- calc_ALD_stats(strategy, ald = ald, |
| 85 | + treatments = ald_trts, |
| 86 | + scale = scale) |
62 | 87 |
|
63 | 88 | stats <- result_stats(ipd_stats, ald_stats, CI) |
64 | 89 |
|
65 | | - structure(stats, |
66 | | - CI = CI, |
67 | | - scale = scale, |
68 | | - model = strategy$family$family, |
69 | | - class = c("outstandR", class(stats))) |
| 90 | + structure( |
| 91 | + stats, |
| 92 | + CI = CI, |
| 93 | + ref_trt = ref_trt, |
| 94 | + scale = scale, |
| 95 | + model = strategy$family$family, |
| 96 | + class = c("outstandR", class(stats))) |
70 | 97 | } |
0 commit comments