Closed esther1262 closed 2 years ago
Hi, the problem with your code is that z1 and z2 were never defined. They are only available as columns with the patients data table.
Hi, errors still popped up for the codes below. Do you have any examples with simulation using parameters directly? The references I found online are all based on fitted models. Thanks
# define true parameters: deltas=shape for each transition; gammas = covariates coefficients
deltas <- matrix(c(1.8, 2.3, 1.3, 2.8, 3, 2.4), nrow=3, byrow=T)
gammas <- c(-1.5, -0.6, 0.3)
# dataframe to store scale parameters adjusted by different covariates
scale_frame <- data.frame(z1=rnorm(n_samples, 0, 1), z2=rbinom(n_samples, 1, 0.5))
scale_frame$logscale <- apply(scale_frame, 1, function(x) gammas %*%c(1,x) )
# parameters for trans 1 to 6
transmod_params <- params_surv_list(
params_surv(coefs = list(shape=rep(log(deltas[1,1]), n_samples), scale=scale_frame), dist = "llogis"),
params_surv(coefs = list(shape=rep(log(deltas[1,2]), n_samples), scale=scale_frame), dist = "llogis"),
params_surv(coefs = list(shape=rep(log(deltas[2,1]), n_samples), scale=scale_frame), dist = "llogis"),
params_surv(coefs = list(shape=rep(log(deltas[2,2]), n_samples), scale=scale_frame), dist = "llogis"),
params_surv(coefs = list(shape=rep(log(deltas[3,1]), n_samples), scale=scale_frame), dist = "llogis"),
params_surv(coefs = list(shape=rep(log(deltas[3,2]), n_samples), scale=scale_frame), dist = "llogis")
)
transmod_cr <- create_IndivCtstmTrans(transmod_params, transmod_data,
trans_mat = tmat, n = n_samples,
clock = "reset")
Error: Not all variables in 'object' are contained in 'input_data'.
Hi, I want to simulate a time inhomogeneous 3-state CTMC or semi-markov, whereas the transition rates are in terms of the hazard function of log-logistic distribution with shape=delta, scale = exp(-delta*b'Z). Covariates effects b are the same across all 6 transitions.
I'm new to hesim package and thus I have few questions.
Can I simulate a markov chain using the package? without first fitting a flexsurvreg model? using create_IndivCtstmTrans?
I read your some guidelines and wrote some codes, but something went wrong.
Regards