Extracts regression coefficients from the term-specific interaction models
stored in an mfpi() fit. Because MFPI evaluates each continuous variable in
a separate interaction model, the method returns one coefficient vector when
a single interaction is requested and a named collection when several
interactions are requested.
# S3 method for mfpi
coef(object, term = NULL, model = c("best", "all"), ...)If one interaction model is requested, a named numeric vector of regression
coefficients with class "mfpi_coef". If several interaction models are
requested, a named list with class "mfpi_coef_list", with one coefficient
vector per interaction. The printed labels are user-facing; the original
fitted coefficient names are retained in the raw_names attribute of each
coefficient vector.
A fitted mfpi() object.
Optional character vector naming continuous variables whose
term-specific interaction models should be extracted. When NULL, all
available terms in the requested model scope are returned.
Character scalar indicating which stored interaction models are
eligible. "best" (the default) uses interactions retained by the MFPI
selection criterion; "all" uses every evaluated term-specific winner,
whether retained or not.
Not used. Supplying additional arguments produces an error.
mfpi() does not fit all selected interactions together in one joint final
model. Each variable in interaction_vars has its own term-specific interaction
model. Consequently, coef.mfpi() reports coefficients from those stored
interaction models rather than from the first-stage MFP adjustment model.
By default, only interactions retained by the MFPI selection criterion are
available (model = "best"). Set model = "all" to extract the fitted
interaction model for every evaluated variable, including interactions that
were not retained. Use term to select one or more continuous variables.
The printed representation is designed for interpretation. For each interaction it reports the interaction variable, grouping variable, FLEX setting, and requested interaction form. The interaction-model FP powers are then shown separately for every group level, irrespective of FLEX. This gives one consistent display for FLEX1--FLEX4 and makes group-specific power choices under FLEX4 explicit.
The coefficients belonging to the group-specific continuous-variable functions are displayed in a table with columns for the original group level, the FP transformation, and the coefficient estimate. Coefficients for the grouping variable are shown in a separate table together with the fitted reference level. The table reports the coefficient attached to each non-reference factor level; it is deliberately not labelled as a direct comparison with the reference group because, in the presence of an interaction, that coefficient is only one component of the model parameterization and is not an overall group effect. For a grouping variable with K levels, there are K group-specific FP blocks and K - 1 group-variable coefficients. Adjustment coefficients are displayed separately, using stored MFP metadata to recover readable variable or transformation labels where available. A model intercept, when present, is also shown separately.
Transformation labels identify the FP basis before centering. When the MFPI
fit uses center = TRUE, the corresponding fitted design columns are centered
using the stored MFPI centering constants; the coefficient estimates are
therefore coefficients of those centered design columns.
The numeric values remain ordinary regression coefficients. For a single requested interaction, the returned object is a numeric vector with an MFPI print class and can be used in numerical calculations. If several interactions are requested, a named list of such vectors is returned. Multinomial results contain the slope coefficients for each non-reference logit; their class-specific intercepts are not included.
The transformation labels reflect the interaction model actually fitted.
Thus, under flex4, different group levels can display different FP
transformations. Repeated FP powers use the standard repeated-power form;
for example, powers c(-2, -2) are displayed as x^-2 and
x^-2 * log(x) (with any fitted shift included in x).
mfpi(), vcov.mfpi(), summary.mfpi(), predict.mfpi()
data("prostate", package = "mfp2")
fit <- mfpi(
lpsa ~ fp(age) + svi + fp(cavol),
data = prostate,
group_var = "svi",
interaction_vars = "cavol",
interaction_forms = c(cavol = "fp2"),
flex = "flex4",
p_interact = 1,
verbose = FALSE
)
# User-facing coefficient display for the selected interaction model.
coef(fit)
# Extract one term explicitly.
b <- coef(fit, term = "cavol")
is.numeric(b)
# Inspect an evaluated interaction even when it was not retained.
coef(fit, term = "cavol", model = "all")
Run the code above in your browser using DataLab