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.
.mcee_fit_nuisance(
config,
data_for_fitting,
data_for_predicting,
lhs_var,
param_name,
data_for_fitting_name
)List with components:
predNumeric vector of length nrow(data_for_predicting)
containing predictions/fitted values.
modelFitted model object (e.g., glm, gam, randomForest)
or a list descriptor for known values.
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 frame subset used to train the model (e.g., available rows only).
Data frame on which to generate predictions (usually full data).
Character. Column name of the response/outcome variable to model.
Character. Descriptive name for error messages (e.g., "p_t(1|H_t)").
Character. Description of fitting data for model call display.
**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.