SOURCEBOOK

R | Data Analysis

Paired Samples t Test

Prior to the steps below, enter the data as appropriate for the analyses (described elsewhere). As always, the following commands should be typed directly in the R console window.

Obtaining Descriptive Statistics

Get the sample sizes, means, and standard deviations for the variables.

lapply(PairedData, function(x) c(length(x), mean(x), sd(x)))

Obtaining Inferential Statistics

Test the mean difference for statistical significance and get its confidence interval.

t.test(Outcome2,Outcome1,paired=TRUE)

Also, you can change the width of the confidence interval if desired.

t.test(Outcome2,Outcome1,paired=TRUE,conf.level=.99)