Section 5: Statements for SAS and SPSS MIXED Models A. Commands with SAS PROC MIXED The examples which follow in subsequent sections demonstrate how the most commonly applied statements from PROC MIXED resemble and how they are different from statements from PROC GLM. In THE PROC MIXED list of keywords, notice that the frequently invoked statements (defined by the initial keywords in capital letters) have several of the same keywords found with PROC GLM; however, there are subtle to major differences to be aware of. PROC MIXED ; WHERE ( eq ); BY ; CLASS ; MODEL dep_var = / ; REPEATED / < options >; RANDOM / < options >; LSMEANS / ; ESTIMATE 'description' | / ; CONTRAST 'description' ; RUN; Very brief descriptions of important points to note for a few of these statements are listed below. More details for their functions will be presented in subsequent sections. PROC MIXED Invokes the procedure and allows entry of several data processing options. CLASS Print classification factors and subject id variable names. MODEL dep_var = cls1 cls2 x1 x2 / solution ddfm=bw ; The variables cls1 and cls2 must appear in the CLASS statement; x1 x2 represent numerical covariates solution : prints a solution to the output ddfm : selects one of several degree of freedom calculation options. REPEATED time / SUBJECT=id TYPE=cs rcorr; The ID variable should always appear on the CLASS statement. If it does not, then you can get peculiar results. Here is what the SAS documentation states: "Continuous variables are permitted as arguments to the SUBJECT=option. PROC MIXED does not sort by the values of the continuous variable; rather, it considers the data to be from a new subject or group whenever the value of the continuous variable changes from the previous observation. Using a continuous variable decreases execution time for models with a large number of subjects or groups and also prevents the production of a large 'Class Levels Information' table." Different results may be obtained for different sort orders. To get correct results, sort by the subject ID and repeated variable (time) first. Note that the repeated variable factor time is not required on the REPEATED statement if the data are sorted; however, it is a good idea to enter it to remind yourself of its function. The rcorr option prints the within-subject correlation matrix of the type specified with TYPE= to the output. Some of these statements perform the same or very similar functions as statements with the same keywords in PROC GLM; however, very important differences are observed with the REPEATED and RANDOM statements. Another advantage of the MIXED model over GLM is the functionality of the LSMEANS (or EMMEANS in SPSS) statements, especially when computing differences between means. The difference can be the most appreciated when combined with the flexibility of the Output Delivery System (see Section 11). B. Placement of Fixed and Random Effects Details showing how to enter fixed and random effects appear in later sections. However, a brief introduction is given here since the MODEL (for fixed effects) and the RANDOM (for random effects) statements are structured quite differently than found with GLM. A very simple example describes how to structure statements to analyze a fixed and/or random effects ANOVA. A two-way design with factors A and B is presented under two scenarios: 1) Factors A, B, and their interaction A*B are all both fixed PROC MIXED METHOD=type3; CLASS a b; MODEL y = a b a*b; RUN; 2) Factor A is fixed; Factors B and A*B are random PROC MIXED method=type3; CLASS a b; MODEL y = a; RANDOM b a*b; * this form of the RANDOM statement is identical to PROC GLM; RUN; In both scenarios the ANOVA results will be the same as produced by GLM. Both factors A and B, whether fixed or random, must appear in the CLASS statement; however, unlike PROC GLM, the random effects in PROC MIXED are placed only in the RANDOM statement. Note that in most situations a model with one factor treated as fixed (A) and the other factor treated as random (B) should also have their interaction defined as random (A*B). C. Basic command lines for Mixed Models with SPSS include: MIXED y BY WITH / FIXED =
| SSTYPE(3) / METHOD = REML / PRINT = R SOLUTION / REPEATED = time | SUBJECT(id) COVTYPE(cs) / EMMEANS = TABLES() COMPARE ADJ(LSD) . The structure of these statements and how they work together appear in subsequent sections of this extended article.