SPSS Syntax from West et al. Linear Mixed Models This example is modified from Chapter 5 of West, Welch, & Gatecki (2007) Linear Mixed Models. Chapman/Hall. They give similar code of R, SAS, Stata, and others. It is a design where each subject gets 4 trials under a control condition followed by 4 more trials under an intervention condition. Treatment has 2 levels. It is the same as Treat, except that this allows them to treat those two variables different (as nominal or continuous, for instance. Also, treat is 0,1 rather than 1,2, which alters the intercept. Time has 4 levels. For my own purposes elsewhere I have coded Time as 0, 1, 3, 6. It would be neater here to use 0,1,2,3 or 1,2,3,4. If you look at West et al. my variable called treatment istheir variable called treatment, time is called region, subject is called animal, and dv is anticipate. The scores are ones that I made up and were analyzed as part of a conditions * trials design where conditions was a between subject variable. See www.uvm.edu/~dhowell/methods/supplements/MixedModelsForRepeatedData1.pdf They use a repeated statement in model 5.3 in a way that I have never seen before. They are trying to force separate intercepts and slopes for each subject in each of the two treatment conditions. Otherwise the intercept would be the value of Y on the first trial of the first treatment for each subject. Similarly for slope. In mixed models the use of the word “random” is confusing. To a plain old analysis of variance person, a random variable is one whose levels are chosen at random. If we were studying three different schools, we would randomly choose 5 classrooms within each school. In replicating this study you would again choose classrooms randomly, and would be unlikely to have the same classrooms as in the first study. In linear mixed models it also means what I have just said, but it is used in a different way as well. To put “time” on the random command we are asking it to generate a separate slope over time for each subject. In other words we are assuming that slopes will not be constant across subjects. If we leave it off and just say Random intercept / … we are saying that each child should be allowed his own intercept. SPSS Syntax as taken, and modified slightly, from West et al. It is often easier to read in the data from drop down menus and skip the first three lines. GET FILE='G:\Mixed Models Repeated\West.sav '. DATASET NAME DataSet6 WINDOW=FRONT. MEANS TABLES=dv BY treatment BY time /CELLS MEAN COUNT STDDEV MIN MAX . GRAPH /LINE(MULTIPLE)MEAN(dv) BY time BY subject /PANEL COLVAR=treatment COLOP=CROSS . * Model 5.1 . * They treat treatment (treat) as a covariate rather than an independent var. I don’t know why. MIXED dv BY time WITH treat /FIXED = time treat time*treat | SSTYPE(3) /METHOD = REML /PRINT = SOLUTION /RANDOM INTERCEPT | SUBJECT(subject) COVTYPE(VC) . * Model 5.1a -- treat as an indep var, not a covariate My modification . MIXED dv BY time treat /FIXED = time treat time*treat | SSTYPE(3) /METHOD = REML /PRINT = SOLUTION /RANDOM INTERCEPT | SUBJECT(subject) COVTYPE(VC) . * Model 5.2 Adds treat as a random variable. This allows each subject to have his . * own slope and his own intercept. MIXED dv BY time WITH treat /FIXED = time treat time*treat | SSTYPE(3) /METHOD = REML /PRINT = SOLUTION G /RANDOM INTERCEPT treat | SUBJECT(subject) COVTYPE(UN) . * Model 5.3 Same as 5.2 except the repeated command lets each subject have own slope and own intercept for each treatment separately. MIXED dv BY time WITH treat /FIXED = time treat time*treat | SSTYPE(3) /METHOD = REML /PRINT = SOLUTION /RANDOM INTERCEPT treat | SUBJECT(subject) COVTYPE(UN) /REPEATED = treatment | SUBJECT(subject*time) COVTYPE(DIAG) . * Model 5.2 (w/ interaction means) . MIXED dv BY time WITH treat /FIXED = time treat time*treat | SSTYPE(3) /METHOD = REML /PRINT = SOLUTION G /RANDOM INTERCEPT treat | SUBJECT(subject) COVTYPE(UN) /EMMEANS = TABLES(time) WITH(treat=1) COMPARE ADJ(BON) /EMMEANS = TABLES(time) WITH(treat=0) COMPARE ADJ(BON) . * Model 5.2 (Diagnostics) . MIXED dv BY time WITH treat /FIXED = time treat time*treat | SSTYPE(3) /METHOD = REML /PRINT = SOLUTION G /RANDOM INTERCEPT treat | SUBJECT(subject) COVTYPE(UN) /SAVE = PRED RESID . PPLOT /VARIABLES=RESID_1 /NOLOG /NOSTANDARDIZE /TYPE=Q-Q /FRACTION=BLOM /TIES=MEAN /DIST=NORMAL. NPAR TESTS /K-S(NORMAL)= RESID_1 /MISSING ANALYSIS. GRAPH /SCATTERPLOT(BIVAR)=PRED_1 WITH RESID_1 BY treatment /MISSING=LISTWISE . * Marginal model with heterogeneous compound symmetry R(i) matrix . MIXED dv BY time treatment /FIXED = time treatment time*treatment | SSTYPE(3) /METHOD = REML /PRINT = SOLUTION R /REPEATED time Treatment | SUBJECT(subject) COVTYPE(CSH) .