KNOWLEDGEBASE - ARTICLE #2105

R and SAS code to perform a nested t-test

Prism 8 introduces nested t-tests, to deal with data that have both actual replicates and technical replicates. "Nested t-test" is not standard jargon. Prism does the calculations by fitting a mixed-effects model. This FAQ provides R and SAS code to show your statistical consultants, so they can understand precisely what Prism is doing. 

Download the Prism 8 file. 

Download the data file used by R and SAS.  ttest_nested.maxwell_16_4.csv

SAS code

FILENAME REFFILE 'ttest_nested.maxwell_16_4.csv';

PROC IMPORT DATAFILE=REFFILE
DBMS=CSV
OUT=gsData;
GETNAMES=YES;
RUN;

PROC MIXED data=gsData METHOD=REML;
CLASS _Room _Condition;
MODEL _Inductive = _Condition;
RANDOM _Room*_Condition / SUBJECT=_Room;
RUN;

 

R code

library(lme4)
options(contrasts = c("contr.sum","contr.poly"))
teachingData<-read.csv("ttest_nested.maxwell_16_4.csv")
model<-lmer(Inductive ~ Condition + (1|Room:Condition), 
data = teachingData, REML = TRUE)
summary(model)
anova(model)

Source

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

 

Explore the Knowledgebase

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