Learn R Programming

rbmiUtils (version 0.3.0)

gcomp_responder: G-computation Analysis for a Single Visit

Description

Performs logistic regression and estimates marginal effects for binary outcomes.

Usage

gcomp_responder(
  data,
  vars,
  reference_levels = NULL,
  var_method = "Ge",
  type = "HC0",
  contrast = "diff"
)

Value

A named list containing estimates and standard errors for treatment comparisons and within-arm means.

Arguments

data

A data.frame with one visit of data.

vars

A list containing group, outcome, covariates, and visit.

reference_levels

Optional vector specifying reference level(s) of the treatment factor.

var_method

Marginal variance estimation method (default: "Ge").

type

Type of robust variance estimator (default: "HC0").

contrast

Type of contrast to compute (default: "diff").

Examples

Run this code
# \donttest{
library(dplyr)
library(rbmi)
library(rbmiUtils)

data("ADMI")

# Prepare data for a single visit
ADMI <- ADMI |>
  mutate(
    TRT = factor(TRT, levels = c("Placebo", "Drug A")),
    STRATA = factor(STRATA),
    REGION = factor(REGION)
  )

dat_single <- ADMI |>
  filter(AVISIT == "Week 24")

vars <- set_vars(
  subjid = "USUBJID",
  visit = "AVISIT",
  group = "TRT",
  outcome = "CRIT1FLN",
  covariates = c("BASE", "STRATA", "REGION")
)

result <- gcomp_responder(
  data = dat_single,
  vars = vars,
  reference_levels = "Placebo"
)

print(result)
# }

Run the code above in your browser using DataLab