mcee_general: Mediated Causal Excursion Effects (configurable nuisance...

View source: R/mcee_general.R

mcee_generalR Documentation

Mediated Causal Excursion Effects (configurable nuisance models)

Description

Like mcee, but each nuisance function is configured explicitly via config_* objects (formula/method/family or known).

Usage

mcee_general(
  data,
  id,
  dp,
  outcome,
  treatment,
  mediator,
  availability = NULL,
  time_varying_effect_form,
  config_p,
  config_q,
  config_eta,
  config_mu,
  config_nu,
  weight_per_row = NULL,
  verbose = TRUE
)

Arguments

data

A data.frame in long format (one row per id-by-decision point).

id

Character. Column name for subject identifier.

dp

Character. Column name for decision point index (must increase strictly within subject).

outcome

Character. Column name for distal outcome (constant within subject).

treatment

Character. Column name for treatment (coded 0/1).

mediator

Character. Column name for mediator.

availability

Optional character. Column name for availability (0/1). If NULL, all rows are treated as available.

time_varying_effect_form

RHS-only formula for the basis f(t) (e.g., ~ 1, ~ dp, ~ poly(dp,2)).

config_p, config_q, config_eta, config_mu, config_nu

Lists created by mcee_config_maker() or helpers (e.g., mcee_config_glm(), mcee_config_known(), mcee_config_ranger(), etc.).

weight_per_row

Optional numeric vector of row weights (nonnegative, length nrow(data)). If NULL, uniform within-id weights are used.

verbose

Logical; print progress messages.

Details

Use this wrapper for observational studies (estimate p) or when you want different learners per nuisance. The same data requirements as mcee apply.

Value

An "mcee_fit" object; see mcee.

See Also

mcee, mcee_userfit_nuisance, mcee_config_maker

Examples

set.seed(1)
n <- 10
T <- 4
id <- rep(1:n, each = T)
dp <- rep(1:T, times = n)
A <- rbinom(n * T, 1, 0.5)
M <- rbinom(n * T, 1, plogis(-0.2 + 0.3 * A + 0.1 * dp))
Y <- ave(0.5 * A + 0.6 * M + 0.1 * dp + rnorm(n * T), id)
dat <- data.frame(id, dp, A, M, Y)

cfg <- list(
    p   = mcee_config_known("p", 0.5),
    q   = mcee_config_glm("q", ~ dp + M),
    eta = mcee_config_glm("eta", ~dp),
    mu  = mcee_config_glm("mu", ~ dp + M),
    nu  = mcee_config_glm("nu", ~dp)
)
fit_gen <- mcee_general(dat, "id","dp","Y","A","M",
    time_varying_effect_form = ~ dp,
    config_p=cfg$p, config_q=cfg$q, config_eta=cfg$eta, config_mu=cfg$mu, config_nu=cfg$nu)

MRTAnalysis documentation built on Sept. 9, 2025, 5:41 p.m.