MarcLavielle / mlxR

mlxR
Other
18 stars 5 forks source link

Getting a syntax error when simulating time dependent markov chain #29

Open esther1262 opened 4 years ago

esther1262 commented 4 years ago

I tried to generate a ctmc where the transition rates are time dependent and with covariates. However, the following codes on R and mlxR keep giving me errors. Does anyone know how to solve it? Thx!!

catModel <- inlineModel(" [LONGITUDINAL] input = {q12, q21}

DEFINITION: y = {type = categorical categories = {0,1} dependence = Markov transitionRate(0,1) = q12 transitionRate(1,0) = q21 }


[INDIVIDUAL] input = {delta12, delta21, gamma1_12, gamma2_12, gamma1_21, gamma2_21, z12, z21, z2} z2 = {type = categorical, categories = {0,1}}

EQUATION: q12 = delta12 (t^(delta12-1))/(1+t^delta12) exp(gamma1_12 z12 + gamma2_12 z2) q21 = delta21 (t^(delta21-1))/(1+t^delta21) exp(gamma1_21 z21 + gamma2_21 z2)


[COVARIATE] input = {z12mean, z12sd, z21mean, z2sd, pZ2}

DEFINITION: z12 = {distribution=normal, mean=z12mean, sd=z12sd} z21 = {distribution=normal, mean=z21mean, sd=z21sd} z2 = {type = categorical, categories = {0,1}, P(z2=0) = pZ2 }

")

init_q <- c(delta12=0.1, delta21=0.001, gamma1_12=0.01, gamma2_12=2, gamma1_21=0.05, gamma2_21=3, z12mean=0, z12sd=5, z21mean=20, z21sd=5, pZ2=0.5) qlist <- list(name=c("y"), time=sort(runif(200,min=0,max=200))) res3 <- simulx(model = catModel, parameter = init_q, output = qlist, settings = list(seed=123))

[ERROR] Parsing failed at line 14, column 2, due to incomplete match.