Log-rank based test for the validity of the Markov assumption
Arguments
- data
Multi-state data in
msdata
format. Should also contain (dummy codings of) the relevant covariates; no factors allowed- id
Column name in
data
containing subject id- formula
Right-hand side of the formula. If NULL will fit with no covariates (formula="1" will also work), offset terms can also be specified.
- transition
Transition number of the transition to be tested (in the transition matrix as attribute to
data
)- grid
Grid of time points at which to compute the statistic
- B
Number of wild bootstrap replications to perform
- fn
A list of summary functions to be applied to the individual zbar traces (or a list of lists)
- fn2
A list of summary functions to be applied to the overall chi-squared trace
- min_time
The minimum time for calculating optimal weights
- other_weights
Other (than optimal) weights can be specified here
- dist
Distribution of wild bootstrap random weights, either "poisson" for centred Poisson (default), or "normal" for standard normal
Value
MarkovTest returns an object of class "MarkovTest", which is a list with the following items:
- orig_stat
Summary statistic for each of the starting states
- orig_ch_stat
Overall chi-squared summary statistic
- p_stat_wb
P-values corresponding to each of the summary statistics for each starting state
- p_ch_stat_wb
P-values for overall chi-squared summary statistic
- b_stat_wb
Bootstrap summary statistics for each of the starting states
- zbar
Individual traces for each of the starting states
- nobs_grid
The number of events after time s for each s in the grid
- Nsub
Number of patients who are ever at risk of the transition of interest
- est_quant
Pointwise 2.5 and 97.5 quantile limits for each of the traces
- obs_chisq_trace
Trace of the chi-squared statistic
- nch_wb_trace
Individual values of the chi-squared statistic trace for the wild bootstrap samples
- n_wb_trace
Individual values of the log-rank z statistic traces for the wild bootstrap samples
- est_cov
Estimated covariance matrix between the log-rank statistics at each grid point
- transition
The transition number tested
- from
The from state of the transition tested
- to
The to state of the transition tested
- B
The number of wild bootstrap replications
- dist
The distribution used in the wild bootstrap
- qualset
Set of qualifying states corresponding to the components of the above traces
- coxfit
Fitted coxph object
- fn
List of functions applied to state-specific trace
- fn2
List of functions applied to overall trace
Details
Function MarkovTest performs the log-rank test described in Titman & Putter (2020). Function optimal_weights_matrix implements the optimal weighting for the state-specific trace. Function optimal_weights_multiple implements the optimal weighting for the chi-squared trace.
References
Titman AC, Putter H (2020). General tests of the Markov property in multi-state models. Biostatistics To appear.
Author
Andrew Titman a.titman@lancaster.ac.uk, transported to mstate by Hein Putter H.Putter@lumc.nl
Examples
if (FALSE) { # \dontrun{
# Example provided by the prothrombin data
data("prothr")
# Apply Markov test to grid of monthly time points over the first 7.5 years
year <- 365.25
month <- year / 12
grid <- month * (1 : 90)
# Markov test for transition 1 (wild bootstrap based on 25 replications, 1000 recommended)
MT <- MarkovTest(prothr, id = "id", transition = 1,
grid = grid, B = 25)
# Plot traces
plot(MT, grid, what="states", idx=1:10, states=rownames(attr(prothr, "trans")),
xlab="Days since randomisation", ylab="Log-rank test statistic",
main="Transition Normal -> Low")
plot(MT, grid,what="overall", idx=1:10,
xlab="Days since randomisation", ylab="Chi-square test statistic",
main="Transition Normal -> Low")
# Example using optimal weights and adjustment for covariates
oweights_fun <-
optimal_weights_matrix(prothr, id = "id", grid=grid, transition = 1,
other_weights=list(
function(x) mean(abs(x),na.rm=TRUE),
function(x) max(abs(x),na.rm=TRUE)))
oweights_chi <- optimal_weights_multiple(prothr, id = "id", grid=grid, transition = 1)
# Formula in MarkovTest only works for continuous covariates and dummy coded variables
# No factors allowed
prothr$prednisone <- as.numeric(prothr$treat == "Prednisone")
MT <- MarkovTest(prothr, id = "id",
formula = "prednisone",
transition = 1,
grid = grid, B = 25,
fn = oweights_fun,
fn2 = list(
function(x) weighted.mean(x, w=oweights_chi, na.rm=TRUE),
function(x) mean(x, na.rm=TRUE),
function(x) max(x, na.rm=TRUE)))
} # }