Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: xtmixed for repeated measures

From   Carrie Petrucci <>
Subject   st: xtmixed for repeated measures
Date   Sun, 13 Nov 2011 20:58:52 -0800

May I request assistance with the syntax for running repeated measures using a linear mixed model approach, using the xtmixed command, with Stata 12? I've spent the better part of 2 days reading all the recommended places, to no avail. I have found a great plain language explanation using SAS and SPSS, but not Stata (chapter written by David Howell). If there is a step-by-step reference on xtmixed understandable to us humble non-statisticians, please point me to it and I'll gladly read it. In the meantime, I hope these questions are fairly simple for someone familiar with how to do this.

This is the SAS and SPSS syntax I'm trying to duplicate - from a chapter by David Howell:

SAS syntax:

Proc Mixed data = wicklongMiss;
class group time subj;
model dv = group time group*time;
repeated time/subject = subj type = AR(1);

SPSS syntax:

  dv BY Group Time
  /FIXED = Group Time Group*Time | SSTYPE(3)
  /EMMEANS = TABLES(Group*Time) .

I hope I have not offended by including syntax from the other statistical programs, but it seemed like the easiest way to illustrate what I'm trying to do.

1. My dataset is long with up to 3 records per person to represent standardized assessments at intake, 3 months, and 6 months; I wish to look at the pattern of change over time and want to be able to look at data for all participants, rather than just those with data at all 3 time points; these are periodic data runs that I do for project staff for whom I do the evaluation work, and they find it quite motivating to hear where there are trends towards improvement.

2. I "xtset" the data, although I'm unsure this was necessary

3. I used the syntax below thus far and it rendered the model output (I've not yet included a between subjects factor as the SAS and SPSS examples above do): 

xtmixed bcs xobs || xpid:

"bcs" is the dependent variable measured at 3 time points;
"xobs" is 1, 3, or 6 to represent intake, 3 months or 6 months;
"xpid" is the individual id for each participant

4. I've also run it this way:

xtmixed bcs i.xobs || xpid:

I assume, but wish to confirm, that both models are valid, with the "i.xobs" incorporating the dummy coding that tests each level of xobs to the first level, which in this case, is intake, which would be an appropriate for this data

5. From there, I cannot figure out the appropriate commands to get the remaining output and to apply a first order autoregression model, which appears to be appropriate for my data. Output in the SAS output that would be helpful to see includes:

(These are titles of tables from the SAS output)
Estimated Correlation Matrix for Groups
Covariance Parameter Estimates
AIC and BIC fit statistics
Type 3 Tests of Fixed Effects

I hope these are easy questions to someone familiar with Stata. Thank you for any assistance you can provide.

Carrie Petrucci, MSW, Ph.D.
Senior Research Associate
15720 Ventura Blvd., PH
Encino, CA 91436
Cell phone: 818.667.9167 (preferred)
Office phone: 818.990.8301
Fax: 818.990.3103

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index