Programming the statistical procedures from SAS

Longitudinal Data Analysis with time as a continuous variable

Accepted Solution Solved
Reply
Contributor
Posts: 58
Accepted Solution

Longitudinal Data Analysis with time as a continuous variable

[ Edited ]

I am trying to conduct a Longitudinal Data Analyses with time as a continuous variable, but it seems that for the repeated statement in proc mixed only allow categorical variables?

 

 

This is my code:

 

proc mixed data=daata;
class subject treat  ;
model response = treat SOKLSCOR duration/s;
repeated duration / subject=subject type=UN;
run; quit;

 

My response  is an interval variable (score, ranging from 0 to 100).

Treatment has 2 arms (nomial)

SOKLSCOR is a covariate (interval variable)

Duration is time in days

Subject is the subject ID

 

When I run this code, I get the following error:

NOTE: PROCEDURE MIXED used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

ERROR: Only class variables allowed in this effect.
NOTE: The SAS System stopped processing this step because of errors.

 

How should I fix this where I can use time as an continious variable?  The code works when using time as a categorical variable (visit 1, visit 2, visit 3..etc.), but I need to treat time as a categorical variable.

 

 

 


Accepted Solutions
Solution
‎01-21-2016 02:10 PM
Valued Guide
Valued Guide
Posts: 684

Re: Longitudinal Data Analysis with time as a continuous variable

Actually, if you have the same number of times in each subject, you can just right:

repeated / subject=subject type=unr;

THat is, nothing before the "/". If you have unbalance, then you need to create another time variable. One way is to create a duplicate variable in a data set, and then specify this is a class variable in mixed.:

data daata; set daata;

time = duration;

proc mixed;

class subject treat time;

model response = treat soklscor duration / s;

repeated time / subject=subject type=unr;

run;

View solution in original post


All Replies
Solution
‎01-21-2016 02:10 PM
Valued Guide
Valued Guide
Posts: 684

Re: Longitudinal Data Analysis with time as a continuous variable

Actually, if you have the same number of times in each subject, you can just right:

repeated / subject=subject type=unr;

THat is, nothing before the "/". If you have unbalance, then you need to create another time variable. One way is to create a duplicate variable in a data set, and then specify this is a class variable in mixed.:

data daata; set daata;

time = duration;

proc mixed;

class subject treat time;

model response = treat soklscor duration / s;

repeated time / subject=subject type=unr;

run;

Contributor
Posts: 58

Re: Longitudinal Data Analysis with time as a continuous variable

[ Edited ]

Lvm,

 

thanks for your response... Even though it is a continious variable, I should put the time variable in the class statement?

 

I think the data is unbalanced, since patients do miss visits. But I did create a record for them. So if take a look at my sample table below, Patient 3 missed his 2nd visit. Because of this, can I treat this as balanced?

 

And to confirm, this is ok to do where there are missing duration (since patients skip visits) and the durations varies (so for example ID=1 and ID 2 had different durations for visit 2.

 

For example:

ID Visit Duration
1 Visit 1 0
1 Visit 2 53
2 Visit 1 0
2 Visit 2 40
3 Visit 1 0
3 Visit 1 .

 

Also, I seem to run into a memory issue when using "repeated time / subject=subject type=un;"  It worked fine when setting the covariance structure to VC, but I need to set it to UN. Any thoughts on how to fix this?

NOTE: 438 observations are not included because of missing values.
ERROR: Unable to allocate sufficient memory: a request for 1954142K bytes exceeded the 786430K available. Note that the deficit amount
       may not be the amount of memory needed for a successful run, since it does not reflect subsequent allocations by this or other
       processes.
ERROR: The SAS System stopped processing this step because of insufficient memory.
NOTE: PROCEDURE MIXED used (Total process time):
      real time           0.34 seconds
      cpu time            0.04 seconds

 

Valued Guide
Valued Guide
Posts: 684

Re: Longitudinal Data Analysis with time as a continuous variable

Yes, the time variable appears in two different forms (with two different names) in the proc. The one version is a class variable (used just in the repeated statement) and the other version is continuous, used in the model statement, etc. The use of the class time variable (whatever you call it) assures that observations are tracked properly in constructing the R covariance matrix. It should take care of missing values, etc. There are examples of this in several places, including in the SAS for Mixed Models, 2nd edtion book.
With the memory problem, you may need to switch to HPMIXED procedure.
Contributor
Posts: 58

Re: Longitudinal Data Analysis with time as a continuous variable

With the missing values, but there is a record for the missing value, can I cosnider my data balanced?

Valued Guide
Valued Guide
Posts: 684

Re: Longitudinal Data Analysis with time as a continuous variable

No, it is unbalanced, whether you put a missing value record or drop those records.
Respected Advisor
Posts: 2,655

Re: Longitudinal Data Analysis with time as a continuous variable

Hmm--do you really need to model an unstructured dataset?  Depending on the number of timepoints (and missingness and spacing), you could run into an overspecified model very quickly.

 

One possibility is to consider a spatial power covariance structure or a splined covariance structure.  There are some very good examples in the documentation for the splined structure, and the spatial power structure is a generalization of the autoregressive structure.

 

Steve Denham

Contributor
Posts: 58

Re: Longitudinal Data Analysis with time as a continuous variable

Yeah we need to specify the the correct covariance structure.  I ran it with VC as the covariance structure and the covtest indicates it is not the correct structure.  So I am trying a few others hopefully. 

 

We have baseline, 3mo, 6mo and end of study visit. But the study was ended early due to adverse events. So the end of study visit varies (some was before the 3 mo visit, which means missing 6mo visits,  some subjects had the 3 mo visit and were never heard of again..etc.). this data is very messy sadly. I will look into the spatial power covariance structure or a splined covariance structure as you suggested

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 684 views
  • 0 likes
  • 3 in conversation