table.state {SemiMarkov} | R Documentation |
Table giving the numbers of observed transitions
Description
Function returning a table with numbers of transitions between two states observed in the data set. This table can be a used to summarize a multi-state data or to define the matrix mtrans
required in the semiMarkov
function.
Usage
table.state( data, states = NULL, mtrans = NULL, cens = NULL)
Arguments
data |
data frame in form
This data.frame containts one row per transition (possibly several rows per patient). |
states |
A numeric vector giving the names of the states (names are values used in |
mtrans |
A quadratic matrix of logical values describing the possible transitions.
The rows represent the left states, and the columns represent the entered states.
If an instantaneous transition is not allowed from state |
cens |
A character giving the code for censored observations in the column |
Value
table.state |
A table, with starting states as rows and arrival states as columns, which provides the number of observed transitions between two states. This argument can be used to quickly summarize multi-state data. |
Ncens |
Number of individuals subjected to censoring. |
Author(s)
Agnieszka Listwon-Krol
See Also
Examples
## Asthma control data
data(asthma)
# default description
# censoring is implicitly defined as a transition "h->h"
table.state(asthma)
table.state(asthma)$Ncens
# censoring defined as a transition to state "4"
asthma_bis<-asthma
for(i in 1:dim(asthma)[1]){if(asthma[i,2]==asthma[i,3]) asthma_bis[i,3]<-4}
table.state (asthma_bis, cens = 4)
## Definition of the model: states names and possible transtions
states_1 <- c("1","2","3")
mtrans_1 <- matrix(FALSE, nrow = 3, ncol = 3)
mtrans_1[1, 2:3] <- TRUE
mtrans_1[2, c(1,3)] <- c("W","E")
table.state(asthma, states = states_1, mtrans = mtrans_1)