KNOWLEDGEBASE - ARTICLE #2104

R and SAS code to fit a mixed-effects model instead of two-way ANOVA with repeated measures in both factors

Prism 8 introduces fitting a mixed-effects model to allow, essentially, repeated measures ANOVA with missing values. We provide R and SAS code to show your statistical consultants, so they can understand what Prism is doing. This example is for two-way ANOVA with repeated measures in both factors. Another FAQs covers one-way repeated measures ANOVA

Download the Prism file (ANOVA2.RM_Maxwell_Delaney_12_1.prism)

Download the data file used by R and SAS (anova2.rm.maxwell_12.1.csv)

SAS Code

FILENAME REFFILE 'anova2.rm.maxwell_12.1.csv';
PROC IMPORT DATAFILE=REFFILE
DBMS=CSV
OUT=gsData;
GETNAMES=YES;
RUN;
PROC MIXED data=gsData METHOD=REML;
CLASS A B S;
MODEL Y = A B A*B;
RANDOM Int A B / SUBJECT=S;
RUN;

R code

options(contrasts = c("contr.sum", "contr.poly"))
fit <- aov(Y ~ A * B + Error(S / (A * B)), data = noiseData)
summary(fit)

Source

Designing Experiments and Analyzing Data: A Model Comparison Perspective (3rd edition; Maxwell, Delaney, & Kelley, 2018), Table 12.5

Explore the Knowledgebase

Analyze, graph and present your scientific work easily with GraphPad Prism. No coding required.