vcov.mfpi: Extract Variance-Covariance Matrices from MFPI Interaction...

View source: R/mfpi_coef_vcov.R

vcov.mfpiR Documentation

Extract Variance-Covariance Matrices from MFPI Interaction Models

Description

Extracts estimated variance-covariance matrices from the term-specific interaction models stored in an mfpi() fit. The method uses the same model scope, term selection, coefficient order, and user-facing labels as coef.mfpi().

Usage

## S3 method for class 'mfpi'
vcov(object, term = NULL, model = c("best", "all"), ...)

Arguments

object

A fitted mfpi() object.

term

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.

model

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.

Details

Each continuous variable evaluated by mfpi() has a separate interaction model. There is therefore no single covariance matrix spanning coefficients from different MFPI interactions. When one term is requested, vcov.mfpi() returns that model's ordinary covariance matrix. When several terms are requested, it returns a named list containing one covariance matrix per term-specific model.

Row and column names correspond exactly to names(coef(object, ...)) for the same interaction model. Group-specific FP coefficients are labelled using the original group levels and readable FP transformations. Group-variable coefficients use labels such as ⁠treatment [Drug A]⁠; the reference level is shown by the coef() print method rather than encoded as a pairwise contrast in the coefficient name.

The covariance matrices are conditional on the functional forms and model selected by MFPI. They do not incorporate the additional uncertainty caused by FP power selection, adjustment-model selection, or interaction selection.

Value

If one interaction model is requested, a numeric square matrix with row and column names matching coef.mfpi(). If several interaction models are requested, a named list with class "mfpi_vcov_list", containing one matrix per interaction. The original fitted coefficient names are retained in the raw_names attribute of each matrix.

See Also

coef.mfpi(), mfpi(), summary.mfpi(), predict.mfpi()

Examples

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
)

V <- vcov(fit, term = "cavol")
dim(V)
identical(rownames(V), names(coef(fit, term = "cavol")))

# `model = "all"` is useful when the evaluated interaction was not retained.
vcov(fit, term = "cavol", model = "all")


mfp2 documentation built on Nov. 14, 2026, 1:06 a.m.