# NOT RUN {
############################
# Example of artificial data
# Seed specification
set.seed(-2578)
# Three possible states (0, 1, 2) including censoring
# Discrete time intervals (1, 2, ... , 10)
datFrame <- data.frame(
ID=c(rep(1, 5), rep(2, 3), rep(3, 2), rep(4, 1), rep(5, 3)),
time=c(c(2, 5, 6, 8, 10), c(1, 6, 7), c(9, 10), c(6), c(2, 3, 4)),
state=c(c(0, 0, 2, 1, 0), c(1, 2, 2), c(0, 1), c(2), c(0, 2, 1)),
x=rnorm(n=5+3+2+1+3) )
# Transformation to long format
datFrameLong <- dataLongMultiSpell(dataSet=datFrame, timeColumn="time",
censColumn="state", idColumn="ID")
head(datFrameLong, 25)
# Fit multi state model without autoregressive terms
library(VGAM)
cRm <- vglm(cbind(e0, e1, e2) ~ timeInt + x, data=datFrameLong,
family="multinomial")
summary(cRm)
# -> There is no significant effect of x (as expected).
# }
Run the code above in your browser using DataLab