Learn R Programming

outstandR (version 1.0.0)

calc_gcomp_ml: G-computation Maximum Likelihood Bootstrap

Description

Computes the mean difference in treatment effects using bootstrap resampling.

Usage

calc_gcomp_ml(strategy, analysis_params)

Value

A list containing:

  • means: A list containing:

    • A: Bootstrap estimates for comparator treatment group "A".

    • C: Bootstrap estimates for reference treatment group "C".

  • model: A list containing the fit object, rho, and N.

Arguments

strategy

A list specifying the model strategy, including:

  • R: Number of bootstrap replications.

  • formula: A linear regression formula object.

  • family: A family object specifying the distribution and link function (e.g., binomial).

  • N: Synthetic sample size for g-computation.

analysis_params

List of analysis parameters.

Examples

Run this code
strategy <- list(
  formula = y ~ trt:X1,
  family = binomial(),
  rho = NA,
  N = 1000L,
  n_boot = 100L,
  marginal_distns = NA,
  marginal_params = NA,
  trt_var = "trt")

ipd <- data.frame(trt = sample(c("A", "C"), size = 100, replace = TRUE),
                  X1 = rnorm(100, 1, 1),
                  y = sample(c(1,0), size = 100, prob = c(0.7,0.3), replace = TRUE))

ald <- data.frame(trt = c(NA, NA, "B", "C", "B", "C"),
                  variable = c("X1", "X1", "y", "y", NA, NA),
                  statistic = c("mean", "sd", "sum", "sum", "N", "N"),
                  value = c(0.5, 0.1, 10, 12, 20, 25))

calc_gcomp_ml(
  strategy,
  analysis_params = 
    list(ipd = ipd, ald = ald, 
         ref_trt = "C", 
         ipd_comp = "A"))
         

Run the code above in your browser using DataLab