Learn R Programming

MRTAnalysis (version 0.4.1)

mcee_config_maker: Build a nuisance-configuration object for mcee_general()

Description

Creates a configuration list describing **how to obtain a nuisance function** used by mcee_general. You may either:

  1. supply **known values** (bypasses learning), or

  2. specify a **learning method** (e.g., GLM/GAM/RF/Ranger/SL) with a formula.

Usage

mcee_config_maker(
  target,
  method = NULL,
  formula = NULL,
  family = NULL,
  known = NULL,
  known_a1 = NULL,
  known_a0 = NULL,
  clipping = NULL,
  SL.library = NULL,
  ...
)

Value

A named list describing the configuration. For known configs:


list(
  nuisance_parameter = <target>,
  known   = <numeric or NULL>,
  known_a1 = <numeric or NULL>,
  known_a0 = <numeric or NULL>,
  clipping = <numeric length-2 or NULL>
)

For learner configs:


list(
  nuisance_parameter = <target>,
  method  = <character>,
  formula = <formula or NULL>,
  family  = <family or NULL>,
  clipping = <numeric length-2 or NULL>,
  SL.library = <character vector; only when method == "sl">
)

Arguments

target

Character; which nuisance to configure. One of "p", "q", "eta", "mu", "nu".

method

Optional character learner name when *not* using known values. Supported:

  • "glm", "gam", "lm" (formula-based);

  • "rf" (randomForest), "ranger";

  • "sl" (SuperLearner).

Ignored if any of known, known_a1, known_a0 is provided.

formula

RHS-only formula describing predictors for the learner (used when method is formula-based; ignored for known). For method = "gam", s() terms are allowed (via mgcv).

family

Optional GLM/GAM family. If NULL, a default is chosen based on target and method (typically binomial() for p/q, gaussian() for eta/mu/nu).

known

Optional numeric scalar/vector of **known values** for the nuisance. Commonly used for target = "p" in MRTs when the randomization probability is known.

known_a1, known_a0

Optional numeric scalar/vector providing known values for the treatment-specific versions of a nuisance (e.g., eta1/eta0, mu1/mu0, nu1/nu0). If supplied, the function returns a "known" config and method/formula/family are ignored.

clipping

Optional numeric vector of length 2, c(lower, upper), to truncate predictions (e.g., probabilities into \([\epsilon, 1-\epsilon]\)). Validated but not required.

SL.library

Character vector of SuperLearner libraries (only used when method = "sl"). If NULL, defaults to c("SL.mean", "SL.glm", "SL.gam").

...

Reserved for future extensions; currently ignored.

Details

If any of known, known_a1, or known_a0 is provided, the returned configuration is of type “known” and **no learner will be fit**. Otherwise, the configuration records the requested learner, formula, family, optional clipping, and (for SL) the library.

Internally, helper validators ensure method is supported and clipping (if provided) is sane. Family defaults are chosen when family = NULL for GLM/GAM methods.

See Also

mcee_general, helper constructors like mcee_config_known(), mcee_config_glm(), mcee_config_gam(), mcee_config_lm(), mcee_config_rf(), mcee_config_ranger(), mcee_config_sl(), mcee_config_sl_user().

Examples

Run this code
# Known p (MRT randomization), GLM for other nuisances
cfg_p <- mcee_config_maker("p", known = 0.5)
cfg_q <- mcee_config_maker("q", method = "glm", formula = ~ dp + M)
cfg_eta <- mcee_config_maker("eta", method = "glm", formula = ~dp)
cfg_mu <- mcee_config_maker("mu", method = "glm", formula = ~ dp + M)
cfg_nu <- mcee_config_maker("nu", method = "glm", formula = ~dp)

# SuperLearner with default library (set explicitly if you prefer)
# cfg_q_sl <- mcee_config_maker("q", method = "sl", formula = ~ dp + M,
#                               SL.library = c("SL.mean","SL.glm","SL.ranger"))

# Known treatment-specific outcome regressions (e.g., from external source)
# cfg_eta_known <- mcee_config_maker("eta", known_a1 = rep(1, 100),
#                                         known_a0 = rep(0, 100))

Run the code above in your browser using DataLab