sambrilleman / simsurv

Simulate Survival Data
GNU General Public License v3.0
22 stars 8 forks source link

setup a longitudinal model with interaction with time #14

Closed zouw2 closed 1 year ago

zouw2 commented 3 years ago

Thanks for sharing this work! Following the notations from the joint model example in the function document, if I want to specify a Z1 by time interaction, do I modify the example by betas[["betaEvent_assoc"]] ( betas[["betaLong_intercept"]] + betas[["betaLong_slope"]] t + betas[["betaLong_slope"]] x[["Z1"]] t + betas[["betaLong_binary"]] x[["Z1"]] + betas[["betaLong_continuous"]] x[["Z2"]] )

or I try to assign different values to betas[["betaLong_slope"]] (according to the value of Z1) Are these 2 approaches the same?

thanks wei

sambrilleman commented 3 years ago

Hi Wei

I think you would want a separate coefficient for the interaction term, so something like:

betas[["betaEvent_assoc"]] * (
  betas[["betaLong_intercept"]] +
  betas[["betaLong_slope"]] * t + 
  betas[["betaLong_slopediff"]] * x[["Z1"]] * t +
  betas[["betaLong_binary"]] * x[["Z1"]] +
  betas[["betaLong_continuous"]] * x[["Z2"]]
)

and I guess that betas[["betaLong_slope"]] would be the slope when x[["Z1"]] = 0, and then betas[["betaLong_slopediff"]] would be the difference in slopes such that betas[["betaLong_slope"]] + betas[["betaLong_slopediff"]] would be the slope when x[["Z1"]] = 1.

Assuming that Z1 was binary? I can't recall from the example.

zouw2 commented 3 years ago

yes, Z1 is binary. Thanks! wei

zouw2 commented 3 years ago

A related question: if I want some random intercept of N(0,1), can I assign betas[["betaLong_intercept"]] as a N(0,1)? So it is not reflected through the hazard function definition; but through the value of beta parameters?

Will it be ok to the numerical procedure if the longitudinal marker has a logistic trajectory: 1/(1+exp(t))? thanks wei

sambrilleman commented 3 years ago

Yeah, you could have a random effect in the definition of the linear predictor for the biomarker. You would probably want it as N(population_mean, sd_random_intercept) though, rather than just N(0,1), if that makes sense.

You could also use the expit transformation for the biomarker, i.e. 1 / (1+exp(XB)) if you want to, although using that in the hazard will probably produce a pretty unstable relationship between the biomarker coefficients and the hazard. Usually it is easier using the linear predictor in the association structure, i.e. XB, rather than the mean itself after applying the inverse link to the linear predictor.

Essentially, the numerical procedure for simsurv will handle any definition for the hazard. It is just up to you to define what hazard function you want.