My question is about using mixed models in SAS. I am a clinical researcher but not a statistician.
I am analysing simulated data for human labour. During labour, the cervix (neck of the womb) dilates from about 1cm to 10cm. Measurements of cervical dilatation are about 2-4 hours apart. The motivation is to simulate data with known parameters and test the validity of a common method of deriving an “average” labour curve, with cervical dilatation on the vertical axis and time on the horizontal axis. The method described in the obstetric literature is a repeated measures high (8th or 10th) order polynomial regression using proc mixed in SAS. Time zero is defined as the first time when the cervix is measured to be 10cm. Time is reversed so that the previous measurements are considered to have occurred in the future (eg a measurement 2 hours before time zero is considered to have occurred at time +2 hours).
For each woman in labour I have a series of simulated measurements (cervical dilatation) and a time-point. The data for the first two ‘women' in labour look like this (I have also attached a sample of the data, first 50000 subjects):
ID Cx BkTm
1 2 12
1 4 8
1 7 4
1 10 0
2 2 12
2 3 8
2 4 4
2 10 0
ID = subject ID; Cx = cervical dilatation (cm); Bktm = time (backwards in time as described above)
The size of the full dataset is 500,000 women.
A journal reviewer has said:
“If the regression slope were allowed to vary depending on the alleged latent/active labour periods, perhaps the results would have changed? To substantiate your conclusion, please tabulate the random-intercept/slope model results with LRTs showing it doesn't provide a better model than the random-intercepts only model you have used.”
My questions are:
(1) What is the correct SAS code for a mixed model with a random intercept?
For the 8th order regression, I used:
proc mixed data = lsr;
class id;
model cx = v v2-v8/ solution;
repeated / subject=id type = cs;
title '?random intercept only';
run;
where v = bktm, v2 = bktm^2, v3 = bktm^3 etc
Which gave identical results to:
proc mixed data=lsr;
class id;
model cx = v v2-v8/ solution;
random intercept / subject=id;
title '?random intercept only';
run;
(2) What is the correct code for a mixed model with random intercepts and random slopes?
I have tried:
proc mixed data=lsr;
class id;
model cx = v v2-v8/ solution;
random intercept v v2-v8 / subject=id;
title ' ?random intercept and slope';
run;
…but this produces the message:
ERROR: Integer overflow on computing amount of memory required. A request to allocate the memory cannot be honored.
ERROR: The SAS System stopped processing this step because of insufficient memory.
(Even though I allocated 20G of RAM to SAS and limited the sample size to 10,000)
(3) If I were to run a model with a random intercept and random slopes, how would I perform the likelihood ratio test requested by the reviewer?
too many random effects.
I would suggest just using:
random int v / subject=id type=un;
Thank you very much for your suggestion.
With a sample size of 500, your suggested code resulted in the message "Estimated G matrix is not positive definite"
With a sample size of 1000 resulted in: "Stopped because of too many likelihood evaluations"
Any further ideas would be very welcome!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.