diagnose: Diagnostics and Patient-Level Validation for RFmstate

View source: R/diagnose.R

diagnoseR Documentation

Diagnostics and Patient-Level Validation for RFmstate

Description

Reports genuine ranger edge-specific OOB concordance. Optionally, complete patient-level cross-validation refits every edge forest and returns IPCW full-state Brier scores and an integrated Brier score.

Usage

diagnose(object, ...)

## S3 method for class 'rfmstate'
diagnose(
  object,
  eval_times = NULL,
  method = c("edge_oob", "cv"),
  folds = 5L,
  repeats = 1L,
  seed = 2026L,
  g_min = 0.05,
  ...
)

Arguments

object

A fitted rfmstate model.

...

Ignored; validation settings must use the documented arguments.

eval_times

Prespecified calendar-time validation horizons. For method="cv", defaults to nine points inside 80 percent of the fitted conservative support.

method

"edge_oob" (default) or "cv".

folds

Positive integer number of patient-level folds for cross-validation.

repeats

Positive integer number of repeated fold assignments.

seed

Nonnegative integer fold-assignment and refit seed.

g_min

Minimum allowed training-fold censoring survival, strictly between zero and one.

Details

Ranger OOB concordance is 1 - prediction.error for each binary cause-specific edge endpoint. It does not validate the assembled multistate probability vector. Full-state scores use subject-level held-out predictions and training-fold Kaplan–Meier censoring estimates. The stronger marginal independent-censoring assumption applies to these KM weights. Fold assignment occurs before schema construction; unordered factor levels and numeric ranges are reconstructed from training subjects only. A held-out-only factor level is an explicit fold failure. No bias–variance decomposition is provided.

Value

An rfmstate_diag object. Edge OOB tables (edge_oob, oob_error, and concordance) are always present. With cross-validation, brier is a full-state IPCW score table, ibs is its trapezoidal integral over integration_interval, and fold assignments/support/seeds are stored in assignments and fold_summary; folds is a backward-compatible alias for fold_summary. The object also records evaluation times, whether their grid was prespecified or exploratory, censoring model, g_min, method, and an explicit validation label.

Limitations

Edge OOB concordance applies only to separate binary cause-specific endpoints and is not a full-pipeline validation score. Cross-validation currently uses a training-fold marginal Kaplan–Meier censoring model and therefore requires marginal independent censoring for the score. Every fold must fit every declared edge and cover all evaluation horizons; failures, sparse edges, or censoring survival below g_min stop validation. No calibration model, prediction interval, or bias–variance decomposition is returned. Automatically generated evaluation times are exploratory and are labeled as such; confirmatory work should supply prespecified times.

Examples


ms <- clinical_states()
dat <- sim_clinical_data(300, structure = ms, seed = 42)
long <- prepare_data(
  dat, "ID", ms,
  list(Responded="time_Responded", Unresponded="time_Unresponded",
       Stabilized="time_Stabilized", Progressed="time_Progressed",
       Death="time_Death"),
  "time_censored", c("age", "sex", "BMI", "treatment")
)
fit <- rfmstate(long, num.trees = 100, min_events = 3, seed = 42)
diagnose(fit)



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