View source: R/mfpi_coef_vcov.R
| vcov.mfpi | R Documentation |
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().
## S3 method for class 'mfpi'
vcov(object, term = NULL, model = c("best", "all"), ...)
object |
A fitted |
term |
Optional character vector naming continuous variables whose
term-specific interaction models should be extracted. When |
model |
Character scalar indicating which stored interaction models are
eligible. |
... |
Not used. Supplying additional arguments produces an error. |
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.
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.
coef.mfpi(), 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
)
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.