In paired-sample designs —also called within-subject designs— the same participants are measured more than once. In that case, asking whether a factor influenced the scores is the same as asking if the factor influenced all the participants. If all the participants turn out to be influenced in the same manner, it can be safely concluded that the factor influenced the group of participants.
Consider a study trying to establish the benefit of using exercises to improve visuo-spatial abilities onto scores in statistics reasoning, as measured by a standardized test with scores ranging from 50 to 150. The design is a within-subject design, specifically a pre-exercises measure and a post-exercises measure of statistics reasoning.
The data are available in dataFigure2
; here is a snapshot of it
head(dataFigure2)
## id pre post
## 1 1 105 128
## 2 2 96 96
## 3 3 88 102
## 4 4 80 88
## 5 5 90 83
## 6 6 86 99
There is a large variation in the scores obtained and as such a t-test where the scores are treated as independent will fail to detect a difference:
library(schoRsch)
t_out(t.test(dataFigure2$pre, dataFigure2$post, var.equal=T))
## Test Results
## 1 Two Sample t-test: t(48) = -1.17, p = .246, d = -0.33
However, examining the data, in which each participant’s scores are shown with a line, we get this:
library(reshape2)
# first transform the data in long format; the pre-post scores will go into column "variable"
dl <- melt(dataFigure2, id="id")
# make a plot, with one color for each participant
ggplot(data=dl, aes(x=variable, y=value, colour=id, group=id)) + geom_line() +
coord_cartesian( ylim = c(70,150) ) +
geom_abline(intercept = 102.5, slope = 0, colour = "red", size = 0.5, linetype=2)
Figure 1: Representation of the individual participants
As seen, except for 5 participants, a vast majority of the participants have an upward trend in their results. Thus, this upward trend is probably a reality in this dataset.
One solution advocated in Cousineau (2005) is to center the participants’ data on the participants’ mean. It consists in computing for each participant their mean score and replace that participant’s mean score with the overall mean. With this manipulation, all the participants will now hover around the overall mean (here 102.5, shown with a red dashed line).
The following realizes this subject-centered plot for each participant.
# use superb:::subject_centering_transform function
df2 <- superb:::subject_centering_transform(dataFigure2, c("pre","post"))
# tranform into long format
dl2 <- melt(df2, id="id")
# make the plot
ggplot(data=dl2, aes(x=variable, y=value, colour=id, group=id)) + geom_line()+
coord_cartesian( ylim = c(70,150) ) +
geom_abline(intercept = 102.5, slope = 0, colour = "red", size = 0.5, linetype=2)
Figure 1: Representation of the subject-centered individual participants
Here again, we see that for 5 participants, their scores went down. For the 20 remaining ones, the trend is upward. Thus, there is clear tendency for the exercices to be beneficial.
Running the adequate paired-t test, we find indeed that the difference is strongly significant (t(24) = 2.9, p = .008):
t_out(t.test(dataFigure2$pre, dataFigure2$post, paired=TRUE))
## Test Results
## 1 Paired t-test: t(24) = -2.90, p = .008, d = -0.58
##
## NOTE: Reporting unadjusted estimate for Cohen's d.
The above suggests that within-subject designs can be much more powerful than between- subject design. As long as there is a general trend visible in most participants, the paired design will afford more statistical power. How to we know that there is a general trend? An easy solution is to compute the correlation across the pairs of scores.
In R, you can run the following:
cor(dataFigure2$pre, dataFigure2$post)
## [1] 0.836611
and you find out that in the present dataset, correlation is actually quite high, with \(r \approx .8\). Whenever correlation is positive, statistical power benefits from correlation.
Because increased power means higher level of precision, the error bars should be shortened by positive correlation. Estimating the adjusted length of the error bars from correlation is a process called decorrelation (Cousineau, 2019).
To this date, three techniques have been proposed to decorrelate the measures. * CM
: This method uses subject-centering followed by a bias-correction step (otherwise the error bars are slightly overestimated) (Cousineau, 2005; Morey, 2008). * LM
: This method also uses subject-centering but when there are more than two measurements, equalizes the length of the error bars using a technique akin to pooled standard deviation measure (Loftus & Masson, 1994). * CA
: this is the newest proposal. It directly uses the correlation (or the mean pairwise correlation when there are more than two measurement) to adjust the error bar length. In a nutshell, the error bar length are adjusted using a multiplicative term \(\sqrt(1-r)\). As an example, with $ r .8$, the adjustment is \(\sqrt(1-.8) = 0.44\). That means that the error bars are 44% the length of the unadjusted error bars.
Whichever method you choose have very little bearing on the actual result. As shown in Cousineau (2019), all three methods are based on the same general concepts and they generate very little difference in the amount of adjustments.
In the present dataset, the error bar are more than shorten by half! which clearly shows the benefit of the within-subject design on precision.
With suberb
, all the decorrelation techniques are available using the adjustment decorrelation
.
Consider the following
library(gridExtra)
## realize the plot with unadjusted (left) and ajusted (right) 95\% confidence intervals
plt2a <- superbPlot(dataFigure2,
WSFactor = "Moment(2)",
adjustments = list(purpose = "difference"),
variables = c("pre","post"),
plotStyle = "line", Quiet = TRUE ) +
xlab("Group") + ylab("Score") +
labs(title="Difference-adjusted\n95% confidence intervals") +
coord_cartesian( ylim = c(85,115) ) +
theme_gray(base_size=10) +
scale_x_discrete(labels=c("1" = "Collaborative games", "2" = "Unstructured activity"))
plt2b <- superbPlot(dataFigure2,
WSFactor = "Moment(2)",
adjustments = list(purpose = "difference", decorrelation = "CA"), #only difference
variables = c("pre","post"),
plotStyle = "line", Quiet = TRUE ) +
xlab("Group") + ylab("Score") +
labs(title="Correlation and difference-adjusted\n95% confidence intervals") +
coord_cartesian( ylim = c(85,115) ) +
theme_gray(base_size=10) +
scale_x_discrete(labels=c("1" = "Collaborative games", "2" = "Unstructured activity"))
plt2 <- grid.arrange(plt2a,plt2b,ncol=2)
Figure 3: Means and 95% confidence intervals on raw data (left) and on decorrelated data (right)
To see the differences between the techniques, I generated random data for 5 measures (when there is only 2, all the techniques are identical) with an amount of correlation of 0.8. In Figure 4 below, all error bars are superimposed on the same plot. As seen, there is only minor differences between the three techniques. Note that the green lines all have the same length.
Figure 4: All three decorelation techniques on the same plot along with un-decorrelated error bars
In superb
, it is possible to ask a certain type of plot. The plotStyle
used so far is "line"
(the default is "bar"
). Another basic style is "point"
(no line connecting the means).
Other types of plot exists that are apt at showing the summary statistics but also the individual scores (the 6th vignettes shows how to develop custom-made styles). For illustrating individual differences, a style proposed is pointindividualline
which — as per Figure 1— will show the individual scores along with the summary statistics and the error bars. For example:
superbPlot(dataFigure2,
WSFactor = "Moment(2)",
adjustments = list(purpose = "difference", decorrelation = "CM"),
variables = c("pre","post"),
plotStyle = "pointindividualline",
Quiet = TRUE ) +
xlab("Group") + ylab("Score") +
labs(subtitle="Correlation- and Difference-adjusted\n95% confidence intervals") +
coord_cartesian( ylim = c(70,150) ) +
theme_gray(base_size=16) +
scale_x_discrete(labels=c("1" = "Collaborative games", "2" = "Unstructured activity"))
Figure 3: Means and 95% confidence intervals on raw data (left) and on decorrelated data (right)
The major obstacle to the use of adjusted error bars was the difficulty to obtain them. None of the statistical software (e.g., SPSS, SAS) provide these adjustments. A way around is to compute these manually. Although not that complicated, it requires manipulations, whether they are done in EXCEL, or macros (e.g., WSPlot, O’Brien & Cousineau, 2014).
The present function renders all the adjustments a mere option in a function.