Diagnose a fitted survatr hazard model

Description

Returns per-period diagnostic panels for a survatr_fit:

positivity
Predicted hazard distribution by time; flags periods with hazards near 0 or 1.
balance
Standardized mean differences (or treatment–confounder correlation for continuous treatment) by time.
weights
IPW only: per-id weight summary (ESS, max, top-5% share). NULL for gcomp / ice.
censoring
Per-period censoring incidence by arm. NULL when no censoring column was supplied.
competing
Competing risks only: per-cause CIF + all-cause survival + identity check Σ F^(j)(t) + S(t) = 1. NULL for single-event fits.

Usage

diagnose(fit, ...)

## S3 method for class 'survatr_fit'
diagnose(fit, ...)

Arguments

fit A survatr_fit returned by surv_fit().
Unused; reserved for future arguments.

Details

Most panels operate on the at-risk rows from build_risk_set() (the rows the hazard model was fit on). Exception: $censoring uses the full person-period grid so that the censoring event itself is visible at the period it occurs; its n_pp_rows denominator therefore includes post-event rows and differs from $positivity$n_at_risk. For the longitudinal ICE-hazard estimator the hazard model is fit lazily inside contrast(), so the positivity panel reports the empirical per-period event rate rather than model-predicted hazards.

Value

A survatr_diag object: a named list with elements positivity, balance, weights, censoring, competing. Each is a data.table indexed by time (and cause for competing), or NULL when the panel does not apply.

See Also

surv_fit(), contrast()

Other survatr_fit functions: print.survatr_diag(), print.survatr_fit(), surv_fit()

Examples

library("survatr")

set.seed(3)
n_id <- 50L; K <- 4L
pp <- data.frame(
  id   = rep(seq_len(n_id), each = K),
  t    = rep(seq_len(K), times = n_id),
  A    = rep(rbinom(n_id, 1L, 0.5), each = K),
  L    = rep(rnorm(n_id), each = K),
  Y    = rbinom(n_id * K, 1L, 0.05)
)
fit <- surv_fit(pp, "Y", "A", ~L, "id", "t", time_formula = ~1)
dx  <- diagnose(fit)
print(dx)
<survatr_diag>
  Positivity:  4 periods, hazards [0.0144, 0.0932]
  Balance:     1 variable(s), SMD range [-0.151, -0.043]
  Censoring:   (no censoring column supplied)