KNOWLEDGEBASE - ARTICLE #2103

R and SAS code to fit a mixed-effects model instead of one-way repeated measures ANOVA

Last modified July 11, 2018

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 one-way repeated measures ANOVA. Another FAQ covers two-way repeated measures ANOVA with repeated measures in both factors

Download the Prism 8 file. 

Download the data file used by R and SAS. Pinheiro_Bates.ergoStool.csv

SAS code

FILENAME REFFILE 'Pinheiro_Bates.ergoStool.csv'; PROC IMPORT DATAFILE=REFFILE
DBMS=CS
OUT=ergoStool;
GETNAMES=YES;
RUN;

PROC MIXED data=ergoStool METHOD=REML;
CLASS effort Type Subject;
MODEL effort=Type;
RANDOM Int / SUBJECT=Subject;
RUN;

R code

library(lme4)
options(contrasts = c("contr.sum","contr.poly"))
ergoStoolData<-read.csv("Pinheiro_Bates.ergoStool.csv")
fm1Stool <- lmer(effort ~ Type + (1|Subject), data = ergoStoolData)
summary(fm1Stool)
anova(fm1Stool)

Source

J. Pinheiro, D. Bates, Mixed-Effects Models in S and S-PLUS, 2000, Section 1.2

Explore the Knowledgebase

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