- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi all.how can i simulate data for repeated measures with auto regressive covariance structure.
appreciate any help.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for writing. The code matches the matrix at the top of the page. However you are correct that the subscripts are confusing. According to my colleague, the symbol that I denote as \sigma_R^2 is usually called the "common covariance" and the symbol that I denote as \sigma^2_{CS} is usually called the "residual covariance." Sorry for the confusion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Not clear if you are talking about time series or mixed models.
Simulating time series with various AR or MA structures is the topic of Chapter 13 of Simulating Data with SAS (Wicklin, 2013).
The easy way is to use the ARMASIM function in SAS/IML software. If you don't have SAS/IML licensed, you can simulate it by using the definition of the AR series in the DATA step (see p. 252).
Mixed models (regression models with correlated errors) are covered in Chapter 12, pp 230-241. For mixed models, you can use PROC IML to set up the covariance structure, The "R" matrix is block diagonal, with each block corresponding to the repeated measurements for each subject.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Dr.Wicklin for your reply .My data is responses of subjects that are measured several times over time in experimental designs of clinical trial. therefore ,since this measures are measures of same subjects that are considered over different times ,that is why they are dependent with each other which leads to having specific covariance structre for example auto regressive or compound symmetry .does the book simulating data with sas contains simulation method for this kind of data?
thanks ,
Fatemeh
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
That sounds like the 10 pages on linear mixed models in Chapter 12. The code for the examples in the book is free and available in a ZIP file from the book's web site.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello ,Dr.Wicklin
I purchased your book simulating data with sas it is wonderful book, helped me to learn how to simulate repeated measures data with fixed and random effects .i have a question in constructing R matrix as variance_covariance matrix of random errors in page 233 chapter12 .I appreciate you help me to solve my problem.why are the non-diagonal elements in R matrix, sigma2_R ? should not they be sigma2_CS ? because when i change the place of sigma2_R and sigma2_CS with each other in proc iml , the R matrix becomes exactly the R matrix that i get when i apply the proc mixed. also in do loop i put k instead of s because i want k*k matrix for R .is it the right way or not?. below is my sas code :
proc mixed data=mydata;
class Subject time treatment ;
model response=time | treatment/ solution outpm=outpm;
random Subject(treatment);
repeated time / type=CS subject=Subject(treatment) R ;
ods select R ;
ods output R=R ;
quit;
proc iml;
k=15;
s=17;
sigma2_R=0.02491;
sigma2_CS=-0.00001;
B=sigma2_CS * j(k,k,1 )+sigma2_R * I(k);
R=B;
do i=2 to k;
R=block(R,b);
end;
R = I(k) @ B;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for writing. The code matches the matrix at the top of the page. However you are correct that the subscripts are confusing. According to my colleague, the symbol that I denote as \sigma_R^2 is usually called the "common covariance" and the symbol that I denote as \sigma^2_{CS} is usually called the "residual covariance." Sorry for the confusion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello.Dr.Wicklin,
I want to construct block diagonal matrix as covariance matrix for errors. Is there any way to create this matrix directly by using the R matrix that is in ods output ?below is my code .it gives me error. appreciate for any help.
proc mixed data=mydata ;
class Subject times responder ;
model response=times|responder/ solution outpm=outpm;
repeated times / type=CS subject=Subject(Responder) R;
ods select R ;
ods output R=R ;
quit;
proc iml;
k=3;
s=5;
R=R /*first block*/
do i=2 to s;
R=block(R,R);
end;
R = I(s) @ R;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The error is because you haven't read R from the data set into a matrix:
use R;
read all var {PUT VAR NAMES HERE} into R;
close;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Dr.Wicklin appreciate for your great answer.it helped me to solve my problem.again thanks a lot for sharing your knowledge with us.