dot-mcee_fit_nuisance: Fit a single nuisance component with flexible learner support

.mcee_fit_nuisanceR Documentation

Fit a single nuisance component with flexible learner support

Description

Internal workhorse function that fits individual nuisance parameters using various machine learning methods or known constants. Handles the complexity of different learner APIs and provides consistent predictions.

Usage

.mcee_fit_nuisance(
  config,
  data_for_fitting,
  data_for_predicting,
  lhs_var,
  param_name,
  data_for_fitting_name
)

Arguments

config

Configuration list describing how to fit the nuisance parameter. Created by mcee_config_maker or helper functions. Contains:

  • **Known values**: known, known_a1, known_a0 (bypasses fitting)

  • **Model-based**: method, formula, family, optional clipping

  • **Method-specific**: SL.library for SuperLearner, learner-specific args

data_for_fitting

Data frame subset used to train the model (e.g., available rows only).

data_for_predicting

Data frame on which to generate predictions (usually full data).

lhs_var

Character. Column name of the response/outcome variable to model.

param_name

Character. Descriptive name for error messages (e.g., "p_t(1|H_t)").

data_for_fitting_name

Character. Description of fitting data for model call display.

Details

**Supported Methods:**

  • "glm": Uses stats::glm() with automatic family detection

  • "lm": Uses stats::lm() (continuous outcomes only)

  • "gam": Uses mgcv::gam() supporting smooth terms

  • "rf": Uses randomForest::randomForest()

  • "ranger": Uses ranger::ranger() (faster random forest)

  • "sl": Uses SuperLearner::SuperLearner()

**Automatic Family Detection:** When family=NULL in GLM/GAM configs: - Binary outcomes (0/1 only): binomial() - Continuous outcomes: gaussian()

**Known Values:** If any of known, known_a1, known_a0 is provided, no model is fitted. Returns constant predictions and a descriptor object.

Value

List with components:

pred

Numeric vector of length nrow(data_for_predicting) containing predictions/fitted values.

model

Fitted model object (e.g., glm, gam, randomForest) or a list descriptor for known values.


MRTAnalysis documentation built on Jan. 24, 2026, 5:07 p.m.