hfNames <- array(rep("Exponential", 16), dim = c(4,4))
hfNames[col(hfNames) <= row(hfNames)]<-"NULL"
rownames(hfNames) <- as.list(paste("state", 1:4))
colnames(hfNames) <- as.list(paste("state", 1:4))
M <- makeM(hfNames)
param <- generateParameterMatrix(M)
param[[1,2]] <- list(rate = 1)
param[[1,3]] <- list(rate = 2)
param[[2,3]] <- list(rate = 0.5)
param[[1,4]] <- list(rate = 1)
param[[2,4]] <- list(rate = 2)
param[[3,4]] <- list(rate = 0.5)
cohort <- simulateCohort(
transitionFunctions = M,
parameters = param,
cohortSize = 100,
to=10)
tmp <- mergeStates(cohort, statesGroup = list(list(1,2), list(3,4)))
merged_cohort <- tmp[["cohort"]]
merged_hfNames <- tmp[["hfNames"]]
Run the code above in your browser using DataLab