Title: | Methods for Checking the Markov Condition in Multi-State Survival Data |
---|---|
Description: | The inference in multi-state models is traditionally performed under a Markov assumption that claims that past and future of the process are independent given the present state. In this package, we consider tests of the Markov assumption that are applicable to general multi-state models. Three approaches using existing methodology are considered: a simple method based on including covariates depending on the history in Cox models for the transition intensities; methods based on measuring the discrepancy of the non-Markov estimators of the transition probabilities to the Markov Aalen-Johansen estimators; and, finally, methods that were developed by considering summaries from families of log-rank statistics where patients are grouped by the state occupied of the process at a particular time point (see Soutinho G, Meira-Machado L (2021) <doi:10.1007/s00180-021-01139-7> and Titman AC, Putter H (2020) <doi:10.1093/biostatistics/kxaa030>). |
Authors: | Gustavo Soutinho [aut, cre] , Luis Meira-Machado [aut] |
Maintainer: | Gustavo Soutinho <[email protected]> |
License: | GPL-3 |
Version: | 0.1.3 |
Built: | 2024-10-31 20:38:22 UTC |
Source: | https://github.com/cran/markovMSM |
This function is used to obtain the local and global tests for checking the Markov condition.
AUC.test( data, from = 1, to = 3, type = "global", times = NULL, quantiles = c(0.05, 0.1, 0.2, 0.3, 0.4), tmat = NULL, replicas = 10, limit = 0.9, positions = list(c(2, 3), c(3), c()), namesStates = c("Alive", "Rec", "Death"), timesNames = c(NA, "time1", "Stime"), status = c(NA, "event1", "event") )
AUC.test( data, from = 1, to = 3, type = "global", times = NULL, quantiles = c(0.05, 0.1, 0.2, 0.3, 0.4), tmat = NULL, replicas = 10, limit = 0.9, positions = list(c(2, 3), c(3), c()), namesStates = c("Alive", "Rec", "Death"), timesNames = c(NA, "time1", "Stime"), status = c(NA, "event1", "event") )
data |
A data frame in long format containing the subject |
from |
The starting state of the transition probabilities. |
to |
The last receiving state considered for the estimation of the transition probabilities. All the probabilities among the first and the last states are also computed. |
type |
Type of test for checking the Markov condition: "local" or "global". By default type='global'. |
times |
For the local test, times represents the starting times of the transition probabilities. In case of a global test, the argument is given by times between the minimum time and the third quartile times used in the formula of this test. Default to NULL. |
quantiles |
Quantiles used in the formula of the Global test for the AUC methods. By default takes the percentiles 0.05, 0.10, 0.20, 0.30, 0.40. |
tmat |
The transition matrix for multi-state model. |
replicas |
Number of replicas for the Monte Carlo simulation to standardization of the T-statistic given by the difference of the areas of AJ and LM transition probabilities estimates. |
limit |
Percentile of the event time used as the upper bound for the computation of the AUC-based test. |
positions |
List of possible transitions; x[[i]] consists of a vector of state numbers reachable from state i. |
namesStates |
A character vector containing the names of either the competing risks or the states in the multi-state model specified by the competing risks or illness-death model. names should have the same length as the list x (for transMat), or either K or K+1 (for trans.comprisk), or 3 (for trans.illdeath). |
timesNames |
Either 1) a matrix or data frame of dimension n x S (n being the number of individuals and S the number of states in the multi-state model), containing the times at which the states are visited or last follow-up time, or 2) a character vector of length S containing the column names indicating these times. In the latter cases, some elements of time may be NA, see Details |
status |
Either 1) a matrix or data frame of dimension n x S, containing, for each of the states, event indicators taking the value 1 if the state is visited or 0 if it is not (censored), or 2) a character vector of length S containing the column names indicating these status variables. In the latter cases, some elements of status may be NA, see Details. |
In case of the AUC global test, an object with a list with the following outcomes:
globalTest |
p-value of AUC global tests for each transition. These values are obtained through the minimum of the means of each two contiguous quantiles times of the AUC global tests. |
localTest |
AUC local tests of the transition probability for each times and transitions. |
quantiles |
Quantiles times used for the AUC global tests. |
times |
Times used for the AUC global tests. |
DIF |
Differences between the AJ and the LMAJ estimates for each transition probabilites from the starting state until the receiving state given by only one replica where 's' represent each of the quantile times. |
from |
The starting state considered for the AUC global tests. |
to |
The last receiving state considered for the the AUC Local tests. |
ET.qiAll |
The lower limit of the diferences between the AJ and the LMAJ
estimates given by the Monte Carlo simulation in each transition for each "s"
quantile times. |
ET.qsAll |
The upper limit of the diferences between the AJ and the LMAJ
estimates given by the Monte Carlo simulation in each transition for each "s"
quantile times. |
replicas |
Number of replicas for the Monte Carlo simulation. |
limit |
Percentil of the times used in the AUC global tests. |
In case of the AUC local test, an object with a list with the following outcomes:
localTest |
p-value of AUC local tests for each times and transitions. |
trans |
The transition matrix describing the states and transitions of the multi-state model. |
times |
Times selected for the AUC Local tests. |
DIF |
Differences between the AJ and the LMAJ estimates for each transition probabilites from the starting state until the receiving state given by only one replica where 's' represent each of the quantile times. |
from |
The starting state considered for the AUC Local tests. |
to |
The last receiving state considered for the the AUC Local tests. |
ET.qiAll |
The lower limit of the diferences between the AJ and the LMAJ
estimates given by the Monte Carlo simulation in each transition for each "s"
quantile times. |
ET.qsAll |
The upper limit of the diferences between the AJ and the LMAJ
estimates given by the Monte Carlo simulation in each transition for each "s"
quantile times. |
replicas |
Number of replicas for the Monte Carlo simulation. |
limit |
Percentil of the times used in the AUC local tests. |
Gustavo Soutinho and Luis Meira-Machado.
Soutinho G, Meira-Machado L (2021). Methods for checking the Markov condition in multi-state survival data. Computational Statistics. de Una-alvarez J, Meira-Machado L (2015). Nonparametric estimation of transition probabilities in the non-Markov illness-death model: A comparative study. Biometrics, 71(2), 364-375. Putter H, Spitoni C (2018). Non-parametric estimation of transition probabilities in non-Markov multi-state models: The landmark Aalen-Johansen estimator. Statistical Methods in Medical Research, 27, 2081-2092. Meira-Machado L, Sestelo M (2019). Estimation in the progressive illness-death model: A nonexhaustive review. Biometrical Journal, 61(2), 245-263.
set.seed(1234) library(markovMSM) data("colonMSM") db_wide<-colonMSM positions<-list(c(2, 3), c(3), c()) namesStates = c("Alive", "Rec", "Death") tmat <-transMatMSM(positions, namesStates) timesNames = c(NA, "time1","Stime") status=c(NA, "event1","event") trans = tmat db_long<- prepMSM(data=db_wide, trans, timesNames, status) res<-AUC.test(data=db_long, times=180, from=1, to=3, type='local', replicas = 20, tmat = tmat) res$localTest res2<-AUC.test(data=db_long, times=180, from=2, to=3, type='local', replicas = 20, tmat = tmat) res2$localTest res3<-AUC.test(data=db_long, from=1, to=3, replicas = 20, tmat=tmat) round(res3$globalTest,3) res4<-AUC.test(data=db_long, from=2, to=3, type='global', replicas = 20, tmat=tmat) round(res4$globalTest,3) round(res4$localTest,3) round(res4$localTest,3) #AUC global for the individuals with the treatment "Obs" of covariate `"rx" #for colonMSM data set set.seed(12345) db_wide.obs<-db_wide[db_wide$rx=='Obs',] db_long.obs <- prepMSM(data = db_wide.obs, trans, timesNames, status) res3a<-AUC.test(data=db_long.obs, times=365, from=1, to=3, type='local', replicas= 20, tmat = tmat) res3a$localTest set.seed(12345) res4a<-AUC.test(data=db_long.obs, times=365, from=2, to=3, type='local', replicas= 20, tmat = tmat) res4a$localTest #' data("ebmt4") db_wide <- ebmt4 positions <- list(c(2, 3, 5, 6), c(4, 5, 6), c(4, 5, 6), c(5, 6), c(), c()) state.names <- c("Tx", "Rec", "AE", "Rec+AE", "Rel", "Death") tmat <-transMatMSM(positions, state.names) timesNames <- c(NA, "rec", "ae","recae", "rel", "srv") status <- c(NA, "rec.s", "ae.s", "recae.s","rel.s", "srv.s") trans <- tmat db_long <- prepMSM(data=db_wide, trans, timesNames, status) db_long[1:10,] res5<-AUC.test(data=db_long, from=1, to=5, type='global', quantiles=c(.05, .10, .20, .30, 0.40), tmat = tmat, replicas = 5, positions=positions, namesStates=state.names, timesNames=timesNames, status=status) round(res5$globalTest, 4) round(res5$localTests,4) res6<-AUC.test(data = prothr, from=2, to=3, type='global', replicas= 5, limit=0.90, quantiles=c(.05, .10, .20, .30, 0.40)) round(res6$globalTest,4) round(res6$localTests,4)
set.seed(1234) library(markovMSM) data("colonMSM") db_wide<-colonMSM positions<-list(c(2, 3), c(3), c()) namesStates = c("Alive", "Rec", "Death") tmat <-transMatMSM(positions, namesStates) timesNames = c(NA, "time1","Stime") status=c(NA, "event1","event") trans = tmat db_long<- prepMSM(data=db_wide, trans, timesNames, status) res<-AUC.test(data=db_long, times=180, from=1, to=3, type='local', replicas = 20, tmat = tmat) res$localTest res2<-AUC.test(data=db_long, times=180, from=2, to=3, type='local', replicas = 20, tmat = tmat) res2$localTest res3<-AUC.test(data=db_long, from=1, to=3, replicas = 20, tmat=tmat) round(res3$globalTest,3) res4<-AUC.test(data=db_long, from=2, to=3, type='global', replicas = 20, tmat=tmat) round(res4$globalTest,3) round(res4$localTest,3) round(res4$localTest,3) #AUC global for the individuals with the treatment "Obs" of covariate `"rx" #for colonMSM data set set.seed(12345) db_wide.obs<-db_wide[db_wide$rx=='Obs',] db_long.obs <- prepMSM(data = db_wide.obs, trans, timesNames, status) res3a<-AUC.test(data=db_long.obs, times=365, from=1, to=3, type='local', replicas= 20, tmat = tmat) res3a$localTest set.seed(12345) res4a<-AUC.test(data=db_long.obs, times=365, from=2, to=3, type='local', replicas= 20, tmat = tmat) res4a$localTest #' data("ebmt4") db_wide <- ebmt4 positions <- list(c(2, 3, 5, 6), c(4, 5, 6), c(4, 5, 6), c(5, 6), c(), c()) state.names <- c("Tx", "Rec", "AE", "Rec+AE", "Rel", "Death") tmat <-transMatMSM(positions, state.names) timesNames <- c(NA, "rec", "ae","recae", "rel", "srv") status <- c(NA, "rec.s", "ae.s", "recae.s","rel.s", "srv.s") trans <- tmat db_long <- prepMSM(data=db_wide, trans, timesNames, status) db_long[1:10,] res5<-AUC.test(data=db_long, from=1, to=5, type='global', quantiles=c(.05, .10, .20, .30, 0.40), tmat = tmat, replicas = 5, positions=positions, namesStates=state.names, timesNames=timesNames, status=status) round(res5$globalTest, 4) round(res5$localTests,4) res6<-AUC.test(data = prothr, from=2, to=3, type='global', replicas= 5, limit=0.90, quantiles=c(.05, .10, .20, .30, 0.40)) round(res6$globalTest,4) round(res6$localTests,4)
These are data from one of the first successful trials of adjuvant chemotherapy for colon cancer. Levamisole is a low-toxicity compound previously used to treat worm infestations in animals; 5-FU is a moderately toxic (as these things go) chemotherapy agent.
data("colonMSM")
data("colonMSM")
A data frame with 929 observations on the following 15 variables. Below a brief description is given for some of these variables.
Time to recurrence/censoring/death, whichever occurs first.
Recurrence/censoring indicator (recurrence=1, alive=0).
Time to censoring/death, whichever occurs first.
Death/censoring indicator (death=1, alive=0).
Treatment - Obs(ervation), Lev(amisole), Lev(amisole)+5-FU.
Sex indicator (male=1, female=0).
Age in years.
Obstruction of colon by tumour.
Perforation of colon.
Adherence to nearby organs.
Number of lymph nodes with detectable cancer.
Differentiation of tumour (1=well, 2=moderate, 3=poor).
Extent of local spread (1=submucosa, 2=muscle, 3=serosa, 4=contiguous structures).
Time from surgery to registration (0=short, 1=long).
More than 4 positive lymph nodes.
The study is originally described in Laurie (1989).The main report is found in Moertel (1990). This data set is closest to that of the final report in Moertel (1991). A version of the data with less follow-up time was used in the paper by Lin (1994).
JA Laurie, CG Moertel, TR Fleming, HS Wieand, JE Leigh, J Rubin, GW McCormack, JB Gerstner, JE Krook and J Malliard. Surgical adjuvant therapy of large-bowel carcinoma: An evaluation of levamisole and the combination of levamisole and fluorouracil: The North Central Cancer Treatment Group and the Mayo Clinic. Journal of Clinical Oncology, 7:1447-1456, 1989.
DY Lin. Cox regression analysis of multivariate failure time data: the marginal approach. Statistics in Medicine, 13:2233-2247, 1994.
CG Moertel, TR Fleming, JS MacDonald, DG Haller, JA Laurie, PJ Goodman, JS Ungerleider, WA Emerson, DC Tormey, JH Glick, MH Veeder and JA Maillard. Levamisole and fluorouracil for adjuvant therapy of resected colon carcinoma. New England Journal of Medicine, 332:352-358, 1990.
CG Moertel, TR Fleming, JS MacDonald, DG Haller, JA Laurie, CM Tangen, JS Ungerleider, WA Emerson, DC Tormey, JH Glick, MH Veeder and JA Maillard. Fluorouracil plus Levamisole as and effective adjuvant therapy after resection of stage II colon carcinoma: a final report. Annals of Internal Medicine, 122:321-326, 1991.
data(colonMSM) head(colonMSM)
data(colonMSM) head(colonMSM)
A data frame of 2279 patients transplanted at the EBMT between 1985 and 1998. These data were used in Fiocco, Putter & van Houwelingen (2008), van Houwelingen & Putter (2008, 2012) and de Wreede, Fiocco & Putter (2011). The included variables are
Patient identification number
Time in days from transplantation to recovery or last follow-up
Recovery status; 1 = recovery, 0 = censored
Time in days from transplantation to adverse event (AE) or last follow-up
Adverse event status; 1 = adverse event, 0 = censored
Time in days from transplantation to both recovery and AE or last follow-up
Recovery and AE status; 1 = both recovery and AE, 0 = no recovery or no AE or censored
Time in days from transplantation to relapse or last follow-up
Relapse status; 1 = relapse, 0 = censored
Time in days from transplantation to death or last follow-up
Relapse status; 1 = dead, 0 = censored
Year of transplantation; factor with levels "1985-1989", "1990-1994", "1995-1998"
Patient age at transplant; factor with levels "<=20", "20-40", ">40"
Prophylaxis; factor with levels "no", "yes"
Donor-recipient gender match; factor with levels "no gender mismatch", "gender mismatch"
data("ebmt4")
data("ebmt4")
A data frame, see data.frame.
Gustavo Soutinho and Luis Meira-Machado.
We acknowledge the European Society for Blood and Marrow Transplantation (EBMT) for making available these data. Disclaimer: these data were simplified for the purpose of illustration of the analysis of competing risks and multi-state models and do not reflect any real life situation. No clinical conclusions should be drawn from these data.
Fiocco M, Putter H, van Houwelingen HC (2008). Reduced-rank proportional hazards regression and simulation-based prediction for multi-state models. Statistics in Medicine 27, 4340-4358.
van Houwelingen HC, Putter H (2008). Dynamic predicting by landmarking as an alternative for multi-state modeling: an application to acute lymphoid leukemia data. Lifetime Data Anal 14, 447-463.
van Houwelingen HC, Putter H (2012). Dynamic Prediction in Clinical Survival Analaysis. Chapman & Hall/CRC Press, Boca Raton.
de Wreede LC, Fiocco M, and Putter H (2011). mstate: An R Package for the Analysis of Competing Risks and Multi-State Models. Journal of Statistical Software, Volume 38, Issue 7.
data(ebmt4) head(ebmt4)
data(ebmt4) head(ebmt4)
Given a data set in long format, for instance generated by msprep, and a transition matrix for the multi-state model, this function counts the number of observed transitions in the multi-state model and gives their percentages.
eventsMSM(data)
eventsMSM(data)
data |
A data frame in long (counting process) format such as the output by prepMSM. |
A list containing two tables, the first, called Frequencies, with the number of observed transitions in the multi-state model occurring in msdata, the second, called Proportions, with the corresponding proportions.
Gustavo Soutinho and Luis Meira-Machado.
library(mstate) data("ebmt4") db_wide <- ebmt4 positions<-list(c(2, 3, 5, 6), c(4, 5, 6), c(4, 5, 6), c(5, 6), c(6), c()) namesStates = c("Tx", "Rec", "AE", "Rec+AE", "Rel", "Death") trans<-transMatMSM(positions, namesStates) timesNames = c(NA, "rec", "ae","recae", "rel", "srv") status=c(NA, "rec.s", "ae.s", "recae.s", "rel.s", "srv.s") db_long<-prepMSM(data=db_wide, trans, timesNames, status) eventsMSM(db_long)
library(mstate) data("ebmt4") db_wide <- ebmt4 positions<-list(c(2, 3, 5, 6), c(4, 5, 6), c(4, 5, 6), c(5, 6), c(6), c()) namesStates = c("Tx", "Rec", "AE", "Rec+AE", "Rel", "Death") trans<-transMatMSM(positions, namesStates) timesNames = c(NA, "rec", "ae","recae", "rel", "srv") status=c(NA, "rec.s", "ae.s", "recae.s", "rel.s", "srv.s") db_long<-prepMSM(data=db_wide, trans, timesNames, status) eventsMSM(db_long)
Function LR.test performs the log-rank test described in Titman & Putter (2020).
LR.test( data, times = times, from, to, replicas = 1000, formula = NULL, fn = list(function(x) mean(abs(x), na.rm = TRUE)), fn2 = list(function(x) mean(x, na.rm = TRUE)), min_time = 0, other_weights = NULL, dist = c("poisson", "normal") )
LR.test( data, times = times, from, to, replicas = 1000, formula = NULL, fn = list(function(x) mean(abs(x), na.rm = TRUE)), fn2 = list(function(x) mean(x, na.rm = TRUE)), min_time = 0, other_weights = NULL, dist = c("poisson", "normal") )
data |
Multi-state data in |
times |
Grid of time points at which to compute the statistic. |
from |
The starting state of the transition to check the Markov condition. |
to |
The last state of the considered transition to check the Markov condition. |
replicas |
Number of wild bootstrap replications to perform. |
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. |
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 |
LR.test returns an object of class "markovMSM", which is a list with the following items:
localTestLR |
p-value of AUC local tests for each times and transitions. |
globalTestLR |
p-value of AUC global tests for each transition |
times |
Grid of time points at which to compute the statistic. |
replicas |
Number of wild bootstrap replications to perform. |
call |
Expression of the LR.test used. |
Gustavo Soutinho and Luis Meira-Machado.
Titman AC, Putter H (2020). General tests of the Markov property in multi-state models. Biostatistics.
set.seed(1234) library(markovMSM) data("colonMSM") positions<-list(c(2, 3), c(3), c()) namesStates = c("Alive", "Rec", "Death") tmat <-transMatMSM(positions, namesStates) timesNames = c(NA, "time1","Stime") status=c(NA, "event1","event") trans = tmat db_long<- prepMSM(data=colonMSM, trans, timesNames, status) res<-LR.test(data=db_long, times=180, from = 2, to = 3, replicas = 1000) res$globalTestLR times<-c(73.5, 117, 223, 392, 681) res2<-LR.test(data=prothr, times=times, from = 2, to = 3, replicas = 1000) res2$localTestLR res2$globalTestLR res3<-LR.test(data=prothr, times=times, from = 2, to = 1, replicas = 1000) res3$localTestLR res3$globalTestLR
set.seed(1234) library(markovMSM) data("colonMSM") positions<-list(c(2, 3), c(3), c()) namesStates = c("Alive", "Rec", "Death") tmat <-transMatMSM(positions, namesStates) timesNames = c(NA, "time1","Stime") status=c(NA, "event1","event") trans = tmat db_long<- prepMSM(data=colonMSM, trans, timesNames, status) res<-LR.test(data=db_long, times=180, from = 2, to = 3, replicas = 1000) res$globalTestLR times<-c(73.5, 117, 223, 392, 681) res2<-LR.test(data=prothr, times=times, from = 2, to = 3, replicas = 1000) res2$localTestLR res2$globalTestLR res3<-LR.test(data=prothr, times=times, from = 2, to = 1, replicas = 1000) res3$localTestLR res3$globalTestLR
This function is used to obtain a global test to check the Markov condition for each transition based on Cox Proportional hazard models.
PHM.test(data, from, to)
PHM.test(data, from, to)
data |
A data frame in long format containing the subject |
from |
The starting state of the transition to check the Markov condition. |
to |
The last state of the considered transition to check the Markov condition. |
An object with a list with the following outcomes:
p.value |
p-value of Cox global tests for each transition. |
from |
The starting state of the transition to check the Markov condition. |
to |
The last state of the considered transition to check the Markov condition. |
Gustavo Soutinho and Luis Meira-Machado.
Kay, R (1986). A Markov model for analyzing cancer markers and disease states in survival studies. Biometrics 42, 457-481. Soutinho G, Meira-Machado L (2021). Methods for checking the Markov condition in multi-state survival data. Computational Statistics.
library(markovMSM) data("colonMSM") db_wide<-colonMSM positions<-list(c(2, 3), c(3), c()) namesStates = c("Alive", "Rec", "Death") tmat <-transMatMSM(positions, namesStates) timesNames = c(NA, "time1","Stime") status=c(NA, "event1","event") trans = tmat db_long<- prepMSM(data=db_wide, trans, timesNames, status) res1<-PHM.test(data=db_long, from = 2, to=3) res1 data("ebmt4") db_wide <- ebmt4 positions=list(c(2, 3, 5, 6), c(4, 5, 6), c(4, 5, 6), c(5, 6), c(6), c()) namesStates = c("Tx", "Rec", "AE", "Rec+AE", "Rel", "Death") tmat <-transMatMSM(positions, namesStates) timesNames = c(NA, "rec", "ae","recae", "rel", "srv") status=c(NA, "rec.s", "ae.s", "recae.s","rel.s", "srv.s") trans = tmat db_long<- prepMSM(data=db_wide, trans, timesNames, status) db_long$trans<-as.factor(db_long$trans) res2<-PHM.test(data=db_long, from = 5, to=6) res2$p.value res2$from res2$to
library(markovMSM) data("colonMSM") db_wide<-colonMSM positions<-list(c(2, 3), c(3), c()) namesStates = c("Alive", "Rec", "Death") tmat <-transMatMSM(positions, namesStates) timesNames = c(NA, "time1","Stime") status=c(NA, "event1","event") trans = tmat db_long<- prepMSM(data=db_wide, trans, timesNames, status) res1<-PHM.test(data=db_long, from = 2, to=3) res1 data("ebmt4") db_wide <- ebmt4 positions=list(c(2, 3, 5, 6), c(4, 5, 6), c(4, 5, 6), c(5, 6), c(6), c()) namesStates = c("Tx", "Rec", "AE", "Rec+AE", "Rel", "Death") tmat <-transMatMSM(positions, namesStates) timesNames = c(NA, "rec", "ae","recae", "rel", "srv") status=c(NA, "rec.s", "ae.s", "recae.s","rel.s", "srv.s") trans = tmat db_long<- prepMSM(data=db_wide, trans, timesNames, status) db_long$trans<-as.factor(db_long$trans) res2<-PHM.test(data=db_long, from = 5, to=6) res2$p.value res2$from res2$to
Plots for the visual inspection for checking the Markov condition through the difference between the AJ and LMAJ from a starting time of the transition probabilities for each transition.
## S3 method for class 'markovMSM' plot(x = object, to=2, quantileOrder = NULL, axis.scale = c(-1, 1), difP = FALSE, ...)
## S3 method for class 'markovMSM' plot(x = object, to=2, quantileOrder = NULL, axis.scale = c(-1, 1), difP = FALSE, ...)
x |
A dataframe in long format in case of the plot with the differences between AJ and LMAJ estimators or a object of class "markovMSM" with the results of the global.test or local.test function. |
to |
The last receiving state considered for the estimation of the transition probabilities. Plot of the transition probabilities between the starting to this state is shown. |
quantileOrder |
Order of the quantil used in the formula of the AUC global test. |
axis.scale |
Limit of the y axis of the plots. |
difP |
Type of plot representing in case of x means the results of the Localtest. If difP=TRUE plot depicts the discrepancies between AJ and LMAJ estimators. If difP=FALSE plot show the AJ and the LMAJ estimates. By default difP=FALSE. |
... |
For future methods. |
No value is returned.
Gustavo Soutinho and Luis Meira-Machado.
Soutinho G, Meira-Machado L (2021). Methods for checking the Markov condition in multi-state survival data. Computational Statistics.
library(markovMSM) data(prothr) res<-AUC.test(data=prothr, times=30, from=1, to=3, type='local', replicas=10) plot(res, to=3, axis.scale=c(-0.25,.25), difP=TRUE) plot(res, to=2, axis.scale=c(0,.25), difP=FALSE) res2<-AUC.test(data=prothr, from=1, to=3, type='global', replicas=10, limit=0.90, quantiles=c(.05, .10, .20, .30, 0.40)) plot(res2, quantileOrder=3, 2, axis.scale=c(-0.05,.15))
library(markovMSM) data(prothr) res<-AUC.test(data=prothr, times=30, from=1, to=3, type='local', replicas=10) plot(res, to=3, axis.scale=c(-0.25,.25), difP=TRUE) plot(res, to=2, axis.scale=c(0,.25), difP=FALSE) res2<-AUC.test(data=prothr, from=1, to=3, type='global', replicas=10, limit=0.90, quantiles=c(.05, .10, .20, .30, 0.40)) plot(res2, quantileOrder=3, 2, axis.scale=c(-0.05,.15))
This function converts a data set which is in wide format (one subject per line, multiple columns indicating time and status for different states) into a data set in long format (one line for each transition for which a subject is at risk). Selected covariates are replicated per subjects.
prepMSM(data, trans, timesNames, status)
prepMSM(data, trans, timesNames, status)
data |
Data frame in wide format in which to interpret time, status, id or keep, if appropriate. |
trans |
Transition matrix describing the states and transitions in the multi-state model. If S is the number of states in the multi-state model, trans should be an S x S matrix, with (i,j)-element a positive integer if a transition from i to j is possible in the multi-state model, NA otherwise. In particular, all diagonal elements should be NA. The integers indicating the possible transitions in the multi-state model should be sequentially numbered, 1,...,K, with K the number of transitions |
timesNames |
Either 1) a matrix or data frame of dimension n x S (n being the number of individuals and S the number of states in the multi-state model), containing the times at which the states are visited or last follow-up time, or 2) a character vector of length S containing the column names indicating these times. In the latter cases, some elements of time may be NA, see Details |
status |
Either 1) a matrix or data frame of dimension n x S, containing, for each of the states, event indicators taking the value 1 if the state is visited or 0 if it is not (censored), or 2) a character vector of length S containing the column names indicating these status variables. In the latter cases, some elements of status may be NA, see Details. |
An object of class "msdata", which is a data frame in long (counting process) format containing the subject id, the covariates (replicated per subject), and from the starting state to the receiving state trans the transition number Tstart the starting time of the transition Tstop the stopping time of the transition status status variable, with 1 indicating an event (transition), 0 a censoring
Gustavo Soutinho and Luis Meira-Machado.
data("ebmt4") db_wide <- ebmt4 positions<-list(c(2, 3, 5, 6), c(4, 5, 6), c(4, 5, 6), c(5, 6), c(6), c()) namesStates = c("Tx", "Rec", "AE", "Rec+AE", "Rel", "Death") trans<-transMatMSM(positions, namesStates) timesNames = c(NA, "rec", "ae","recae", "rel", "srv") status=c(NA, "rec.s", "ae.s", "recae.s", "rel.s", "srv.s") prepMSM(data=db_wide, trans, timesNames, status)
data("ebmt4") db_wide <- ebmt4 positions<-list(c(2, 3, 5, 6), c(4, 5, 6), c(4, 5, 6), c(5, 6), c(6), c()) namesStates = c("Tx", "Rec", "AE", "Rec+AE", "Rel", "Death") trans<-transMatMSM(positions, namesStates) timesNames = c(NA, "rec", "ae","recae", "rel", "srv") status=c(NA, "rec.s", "ae.s", "recae.s", "rel.s", "srv.s") prepMSM(data=db_wide, trans, timesNames, status)
Returns the formula and the methods of the Markov tests in Multi-state models.
## S3 method for class 'markovMSM' print(x, ...)
## S3 method for class 'markovMSM' print(x, ...)
x |
A object of "markovMSM" with the results of the AUC global or local tests. |
... |
For future methods. |
The formula and the methods of the Markov tests in Multi-state models.
Gustavo Soutinho and Luis Meira-Machado.
Soutinho G, Meira-Machado L (2021). Methods for checking the Markov condition in multi-state survival data. Computational Statistics.
library(markovMSM) data("colonMSM") db_wide<-colonMSM positions<-list(c(2, 3), c(3), c()) namesStates = c("Alive", "Rec", "Death") tmat <-transMatMSM(positions, namesStates) timesNames = c(NA, "time1","Stime") status=c(NA, "event1","event") trans = tmat db_long<- prepMSM(data=db_wide, trans, timesNames, status) times=365 res<-AUC.test(data = db_long, times=times, from=2, to=3, type='local', replicas=2, tmat = tmat) print(res)
library(markovMSM) data("colonMSM") db_wide<-colonMSM positions<-list(c(2, 3), c(3), c()) namesStates = c("Alive", "Rec", "Death") tmat <-transMatMSM(positions, namesStates) timesNames = c(NA, "time1","Stime") status=c(NA, "event1","event") trans = tmat db_long<- prepMSM(data=db_wide, trans, timesNames, status) times=365 res<-AUC.test(data = db_long, times=times, from=2, to=3, type='local', replicas=2, tmat = tmat) print(res)
A data frame of 488 liver cirrhosis patients from a randomized clinical trial concerning prednisone treatment in these patients. The dataset is in long format. The included variables are
Patient identification number
Starting state
Receiving state
Transition number
Starting time
Transition time
Status variable; 1=transition, 0=censored
Treatment; factor with levels "Placebo", "Prednisone"
data("prothr")
data("prothr")
A data frame, see data.frame.
Gustavo Soutinho and Luis Meira-Machado.
This data was kindly provided by Per Kragh Andersen. It was introduced in Andersen, Borgan, Gill & Keiding (1993), Example 1.3.12, and used as illustration for computation of transition probabilities in multi-state models, see Sections IV.4 (Example IV.4.4) and VII.2 (Example VII.2.10).
Andersen PK, Borgan O, Gill RD, Keiding N (1993). Statistical Models Based on Counting Processes. Springer, New York.
data(prothr) head(prothr)
data(prothr) head(prothr)
Returns the p-values of the AUC global and Local tests. Further information on the test are also given.
## S3 method for class 'markovMSM' summary(object, ...)
## S3 method for class 'markovMSM' summary(object, ...)
object |
A object of "markovMSM" with the results of the AUC global or local tests. |
... |
For future methods. |
The p-values of the AUC global and Local tests. Further information on the test are also given.
Gustavo Soutinho and Luis Meira-Machado.
Soutinho G, Meira-Machado L (2021). Methods for checking the Markov condition in multi-state survival data. Computational Statistics.
library(markovMSM) data("colonMSM") db_wide<-colonMSM positions<-list(c(2, 3), c(3), c()) namesStates = c("Alive", "Rec", "Death") tmat <-transMatMSM(positions, namesStates) timesNames = c(NA, "time1","Stime") status=c(NA, "event1","event") trans = tmat db_long<- prepMSM(data=db_wide, trans, timesNames, status) times=365 res<-AUC.test(data = db_long, times=times, from=2, to=3, type='local', replicas=2, tmat = tmat) res$localTest summary(res)
library(markovMSM) data("colonMSM") db_wide<-colonMSM positions<-list(c(2, 3), c(3), c()) namesStates = c("Alive", "Rec", "Death") tmat <-transMatMSM(positions, namesStates) timesNames = c(NA, "time1","Stime") status=c(NA, "event1","event") trans = tmat db_long<- prepMSM(data=db_wide, trans, timesNames, status) times=365 res<-AUC.test(data = db_long, times=times, from=2, to=3, type='local', replicas=2, tmat = tmat) res$localTest summary(res)
Define transition matrices for multi-state model. Specific functions for defining such transition matrices are pre-defined for common multi-state models like the competing risks model and the illness-death model.
transMatMSM(positions, namesStates)
transMatMSM(positions, namesStates)
positions |
List of possible transitions; x[[i]] consists of a vector of state numbers reachable from state i. |
namesStates |
A character vector containing the names of either the competing risks or the states in the multi-state model specified by the competing risks or illness-death model. names should have the same length as the list x (for transMat), or either K or K+1 (for trans.comprisk), or 3 (for trans.illdeath). |
A transition matrix describing the states and transitions in the multi-state model.
Gustavo Soutinho and Luis Meira-Machado.
data("ebmt4") db_wide <- ebmt4 positions<-list(c(2, 3, 5, 6), c(4, 5, 6), c(4, 5, 6), c(5, 6), c(6), c()) namesStates = c("Tx", "Rec", "AE", "Rec+AE", "Rel", "Death") transMatMSM(positions, namesStates)
data("ebmt4") db_wide <- ebmt4 positions<-list(c(2, 3, 5, 6), c(4, 5, 6), c(4, 5, 6), c(5, 6), c(6), c()) namesStates = c("Tx", "Rec", "AE", "Rec+AE", "Rel", "Death") transMatMSM(positions, namesStates)