| Title: | Multistate Model Bias-Corrected Robust Variance |
|---|---|
| Description: | Computes robust and bias-corrected sandwich variance estimators for multi-state Cox models with clustered time-to-event data. The methodology extends the marginal Cox model bias-correction framework of Wang et al. (2023) <doi:10.1002/bimj.202200113> to the multi-state setting. |
| Authors: | Can Meng [aut, cre], Denise Esserman [aut], Fan Li [aut], Erich Greene [aut] |
| Maintainer: | Can Meng <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.0 |
| Built: | 2026-05-31 07:40:35 UTC |
| Source: | https://github.com/cran/mmbcv |
Computes several sandwich variance estimators (robust, MR, MD, FG, KC, MBN and combinations) for multistate Cox models using cluster-level score aggregation, with Breslow or Efron ties.
MMBCV( fit, data, StartTime, StopTime, ClusterID, SubjectID, Event, tie = c("breslow", "efron"), details = FALSE, detail_names = NULL, kc_tol = 1e-10 )MMBCV( fit, data, StartTime, StopTime, ClusterID, SubjectID, Event, tie = c("breslow", "efron"), details = FALSE, detail_names = NULL, kc_tol = 1e-10 )
fit |
A fitted multistate Cox model object with components |
data |
A data.frame in counting-process form that matches the fit. |
StartTime, StopTime
|
Unquoted column names for start/stop times. |
ClusterID |
Unquoted column name for the cluster identifier. |
SubjectID |
Unquoted column name for the subject identifier. |
Event |
Unquoted column name for the event/state indicator used to define transition-specific events. |
tie |
Tie-handling method: |
details |
Logical; if TRUE, returns additional intermediate quantities. |
detail_names |
Optional character vector specifying which extra components
of the full sandwich object to append when |
kc_tol |
Numeric tolerance used in the KC positive-semidefinite adjustment. |
A list containing variance-covariance matrices:
Standard cluster-robust sandwich variance estimator.
Martingale-residual (MR) bias-corrected variance estimator.
Mancl-DeRouen (MD) bias-corrected variance estimator.
Hybrid Mancl-DeRouen plus martingale-residual (MDMR) bias-corrected variance estimator.
Fay-Graubard (FG) bias-corrected variance estimator.
Hybrid Fay-Graubard plus martingale-residual (FGMR) bias-corrected variance estimator.
Kauermann-Carroll (KC) bias-corrected variance estimator.
Hybrid Kauermann-Carroll plus martingale-residual (KCMR) bias-corrected variance estimator.
Morel-Bokossa-Neerchal (MBN) bias-corrected variance estimator.
Hybrid Morel-Bokossa-Neerchal plus martingale-residual (MBNMR) bias-corrected variance estimator.
If details = TRUE, additional intermediate matrices may also be returned.
Wang, X., Turner, E. L., and Li, F. (2023). Improving sandwich variance estimation for marginal Cox analysis of cluster randomized trials. Biometrical Journal, 65, 2200113.
Schaubel, D. E. (2005). Adjusting analytic inference for small samples in recurrent event regression. Statistics in Medicine, 24(19), 3037–3051.
Kauermann, G., and Carroll, R. J. (2001). A note on the efficiency of sandwich covariance matrix estimation. Journal of the American Statistical Association, 96(456), 1387–1396.
Fay, M. P., and Graubard, B. I. (2001). Small-sample adjustments for Wald-type tests using sandwich estimators. Biometrics, 57(4), 1198–1206.
Mancl, L. A., and DeRouen, T. A. (2001). A covariance estimator for GEE with improved small-sample properties. Biometrics, 57(1), 126–134.
Morel, J. G., Bokossa, M., and Neerchal, N. K. (2003). Small sample correction for the variance of GEE estimators. Biometrical Journal, 45(4), 395–409.
Therneau, T., Crowson, C., and Atkinson, E. (2026).
Multi-state models and competing risks.
Vignette for the survival package.
See vignette("compete", package = "survival") or
https://CRAN.R-project.org/package=survival.
data("msdat3") # Example requires the suggested package 'survival' if (requireNamespace("survival", quietly = TRUE)) { fit <- survival::coxph( list( survival::Surv(Tstart, Tstop, event) ~ 1, state("(s0)"):state("S1") + state("S1"):state("S2") + state("S2"):state("S3") ~ Z + X, state("(s0)"):state("D") + state("S1"):state("D") + state("S2"):state("D") + state("S3"):state("D") ~ (Z + X)/common ), data = msdat3, id = id, ties = "breslow", timefix = FALSE ) MMBCV( fit = fit, data = msdat3, StartTime = Tstart, StopTime = Tstop, ClusterID = clus_id, SubjectID = id, Event = event, tie = "breslow", details = FALSE) }data("msdat3") # Example requires the suggested package 'survival' if (requireNamespace("survival", quietly = TRUE)) { fit <- survival::coxph( list( survival::Surv(Tstart, Tstop, event) ~ 1, state("(s0)"):state("S1") + state("S1"):state("S2") + state("S2"):state("S3") ~ Z + X, state("(s0)"):state("D") + state("S1"):state("D") + state("S2"):state("D") + state("S3"):state("D") ~ (Z + X)/common ), data = msdat3, id = id, ties = "breslow", timefix = FALSE ) MMBCV( fit = fit, data = msdat3, StartTime = Tstart, StopTime = Tstop, ClusterID = clus_id, SubjectID = id, Event = event, tie = "breslow", details = FALSE) }
A simulated clustered, subject-level multistate dataset in long (counting-process) format. Treatment is assigned at the cluster level and baseline covariates are available at both the cluster and individual levels. Each subject may contribute multiple rows, corresponding to transitions between states over time.
data(msdat3)data(msdat3)
A data frame with 3,004 rows and 9 variables:
Subject identifier. There are 1,500 unique subjects.
Cluster-level treatment assignment indicator. Z = 1 indicates the
cluster is assigned to treatment; Z = 0 indicates control.
Individual-level baseline covariate generated from a standard normal distribution.
Cluster identifier. There are 30 clusters.
Starting state for the current observation interval (e.g., (s0)).
Ending state for the current observation interval (e.g., S1, S2,
S3, D, or censor).
Start time of the interval.
Stop time of the interval.
End state at Tstop. Values include censor, S1, S2,
S3, and D, where D is the absorbing state.
The multistate process uses the following state labels:
(s0): initial (starting) state.
S1: first intermediate transition state.
S2: second intermediate transition state.
S3: third intermediate transition state.
D: absorbing (terminal) state.
Each row represents a time interval [Tstart, Tstop] during which the subject is
at risk for the transition indicated by from and to. The variable
event records the state at which the interval ends. event = "censor"
indicates the observation is right-censored at Tstop (i.e., no transition is
observed at the end of the interval).
The distribution of event in this dataset is:
censor: 1050
S1: 837
S2: 450
S3: 217
D: 450
Simulated data bundled with the package for examples and testing.
data("msdat3") nrow(msdat3) length(unique(msdat3$id)) length(unique(msdat3$clus_id)) table(msdat3$event)data("msdat3") nrow(msdat3) length(unique(msdat3$id)) length(unique(msdat3$clus_id)) table(msdat3$event)
Subset a dataset by transition using a row map
subset_by_transition(dataA, dataB, transition)subset_by_transition(dataA, dataB, transition)
dataA |
Full dataset to subset. |
dataB |
Two-column object: column 1 = row indices in |
transition |
Character vector of transition names used as output list names. |
A named list of data frames, one per transition.