Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# st: xtmixed for repeated measures

 From Carrie Petrucci To statalist@hsphsun2.harvard.edu 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);
run;

SPSS syntax:

MIXED
dv BY Group Time
/CRITERIA = CIN(95) MXITER(100) MXSTEP(5) SCORING(1)
SINGULAR (0.000000000001) HCONVERGE(0, ABSOLUTE0 LCONVERGE(0, ABSOLUTE)
PCONVERGE (0.000001, ABSOLUTE)
/FIXED = Group Time Group*Time | SSTYPE(3)
/METHOD = REML
/PRINT = DESCRIPTIVES SOLUTION
/REPEATED = Time | SUBJECT(Subj) COVTYPE (AR(1))
/EMMEANS = TABLES(Group)
/EMMEANS = TABLES(Time)
/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
EMT
15720 Ventura Blvd., PH
Encino, CA 91436
Cell phone: 818.667.9167 (preferred)
Office phone: 818.990.8301
Fax: 818.990.3103
www.emt.org
Email: cpetrucci@emt.org

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```