Hi I have a longtudinal data where subjects were followed over 7 years and their stress scores(RESPONSE) were recorded as wave measurements W1,W2,W3. The time in which these scores were recorded is time1,time2,time3 and are uneqaully spaced.
I have written some codes below and would like to find out if they were correct. Hope someone would be able to help me out
so in excel, the columns are such
id age W1 W2 W3 time1 time2 time3
1 23 3 5 0 02-sep-2003 05-oct-2005 09/aug/2007
2 29 0 1 7 05-sep-2003 11-sep-2005 17/dec/2007
.................................
.................................
*changing from wide to longitudinal data*
data long_depression;
set depression;
array AW(1:3) W1-W3 ;
array Atime(1:3) time1-time3;
do visit=1 to 3;
W=AW[visit];
time=Atime[visit];
output;
end;
drop W1-W3 time1-time3;
run;
proc print data=long_depression;
run;
*age,linear mixed effects model*
proc mixed data=long depression;
class id ;
model W = time age time*age/s chisq;
random intercept /type=un subject=ptno g v vcorr;
run;
I'd think that you should not use time as a calendar time but rather time from the baseline i.e. for each subject the earliest time when the response was rrecorded . Your code appears to be correct. I see that you have variable ID in the data set so you should specify SUBJECT=ID in the RANDOM statement.
Also, I'm not sure why you have chisq option and even if such option exists. Not sure about g v vcorr options as I never use options in the RANDOM statement.