importance: Feature Importance per Transition

View source: R/importance.R

importanceR Documentation

Feature Importance per Transition

Description

Extracts and organizes variable importance scores from the fitted random forest models for each transition. These are ranger permutation-importance scores based on edge-specific OOB predictive loss, not causal effects.

Usage

importance(object, ...)

## S3 method for class 'rfmstate'
importance(object, ...)

Arguments

object

A fitted rfmstate model (must have been fit with importance != "none").

...

Ignored.

Details

Values are transition-specific and may have different effective sample sizes. Negative values can arise from Monte Carlo variation, sparse events, correlated predictors, or noise; they do not indicate protective or causal effects. Repeated seeds/resamples are needed to assess stability.

Value

An object of class "rfmstate_importance" containing:

importance

Data frame with columns variable, from, to, transition, n_events, and importance.

importance_matrix

Matrix with variables as rows and transitions as columns.

covariates

Covariate names.

transitions

Character vector of transition labels.

Limitations

Importance describes transition-specific predictive contribution under the fitted ranger endpoint. Values are not causal effects, are not directly comparable across edges with different risk sets/event counts, and do not validate the assembled full-state probability model. Models fitted with importance = "none" return unavailable values.

Examples


ms <- clinical_states()
dat <- sim_clinical_data(n = 200, structure = ms, seed = 42)
msdata <- prepare_data(
  data = dat, id = "ID", structure = ms,
  time_map = list(
    Responded = "time_Responded",
    Unresponded = "time_Unresponded",
    Stabilized = "time_Stabilized",
    Progressed = "time_Progressed",
    Death = "time_Death"
  ),
  censor_col = "time_censored",
  covariates = c("age", "sex", "BMI", "treatment")
)
fit <- rfmstate(msdata, num.trees = 100, seed = 42)
imp <- importance(fit)
print(imp)



RFmstate documentation built on Sept. 10, 2026, 1:09 a.m.