table.state: Table giving the numbers of observed transitions

Description Usage Arguments Value Author(s) See Also Examples

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

1
table.state( data, states = NULL, mtrans = NULL, cens = NULL)

Arguments

data

data frame in form data.frame(id,state.h,state.j,time), where

  • id: the individual identification number

  • state.h: state left by the process

  • state.j: state entered by the process

  • time: waiting time in state state.h

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 state.h).

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 h to state j, then mtrans should have (h,j) entry FALSE, otherwise it should be TRUE. Default value is a matrix which allows all the possible transitions between states.

cens

A character giving the code for censored observations in the column state.j of the data. Default is NULL which means that the censoring is defined as a transition fron state i to state i (by definition of a semi-Markov model, the transitions into the same state are not possible).

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

param.init, semiMarkov

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## 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)

   

SemiMarkov documentation built on July 2, 2019, 5:03 p.m.