New Contributor
Posts: 2

# Anyone knows SAS codes to simulate 'Joint Model of Longitudinal and Survival Data'?

Hi,

Does anyone have sample SAS codes to simulate  'Joint Model of Longitudinal and Survival Data'?

Model specification is in the attached.

Thanks,

SAS Super FREQ
Posts: 4,181

## Re: Anyone knows SAS codes to simulate 'Joint Model of Longitudinal and Survival Data'?

This is pretty complicated, so I hope you already know how to simulate mixed models and survival functions. You have privately comunicated with me that you have my book Simulating Data with SAS, so study the relevant sections in the book to help carry out steps 4) and 5) below.

The model is explained in Section 2.1-2.3.  There are actually 12 models in this paper (Table 2). I'll describe the main ideas.

1) Choose a model in Table 2.

2) Choose parameters from the "Joint analysis" column of Table 3: fixed effects (beta) coefficients, covariance matrix (Sigma), and random coefficients (gamma)

3) For the m subjects, generate U, which is an mx2 matrix that contains m MVN(0, Sigma) observations. Since you posted this question to the IML forum, you can use

U = RandNormal(m, {0 0}, Sigma);  /* random intercepts and slopes */

The i_th row of U is used for the random intercepts and slopes for the i_th patient.

4) If you aren't using a time-varying survival function (such as the exponential hazard function), use Eqn 2 or the Cox PH model to draw a survival time for the i_th patient.

5) Use the mixed model (Eqn 1) to simulate the correlated longitudinal data for the i_th patient. Be sure to stop when the measurement time s_{ij} is greater than the survival time, and mark that patient as censored.

Good luck!

I do not cover time-varying survival functions in my book, but after you are able to simulate the case of constant hazard you can post your program and maybe someone can help you modify it to handle the time-varying case.

New Contributor
Posts: 2

## Re: Anyone knows SAS codes to simulate 'Joint Model of Longitudinal and Survival Data'?

In your book, section 8.8 (Cholesky Transformation) did use the following to generate uncorrelated random intercepts and slopes.

U = RandNormal(m, {0 0}, Sigma);  /* random intercepts and slopes */

But, the last paragraph on page 18 of the attached article has parameter r1, r2, r3 for random intercepts, slopes, and fitted longitudinal value at the event time W1i(t) respectively.

How can you connect the above 2x2 matrix of U with W1i(t)?

SAS Super FREQ
Posts: 4,181

## Re: Anyone knows SAS codes to simulate 'Joint Model of Longitudinal and Survival Data'?

That sentence merely notes that since W1i(t) = U1i + U2i(t), then eqn 4 becomes

W2i(t) = gamma1 U1i + gamma2 U2i(t) + gamma3 W1i(t) + U3i.

The same U matrix is used for both W1 and W2.  That's the whole point of the article. The columns of the U matrix are latent variables that correlate the longitudinal model and the survival model.

Discussion stats
• 3 replies
• 359 views
• 0 likes
• 2 in conversation