Suppose an experiment was conducted to test whether Working Memory (WM) training works as well as Study Program (SP) training
to boost performance on a university admission test (UAT). Assume that high school students were recruited and randomly assigned
to ONE (1) of TWO (2) conditions: WM training or SP training. Further assume that EACH student was tested on the UAT BEFORE and
AFTER training (so we have pre- and post-training scores on the UAT). Use the data in DAA.04.txt.
Round to TWO (2) significant digits (for example, if the correlation is .456 then write .46).
library(psych)
#
# |------------------------------------------------------------------------------------------|
# | I N I T I A L I Z A T I O N |
# |------------------------------------------------------------------------------------------|
Init <- function(fileStr, workDirStr = "C:/Users/denbrige/100 FxOption/103 FxOptionVerBack/080 Fx Git/R-nonsource") {
setwd(workDirStr)
retDfr <- read.table(fileStr, header = T)
return(retDfr)
}
#
# |------------------------------------------------------------------------------------------|
# | M A I N P R O C E D U R E |
# |------------------------------------------------------------------------------------------|
# --- Init loading raw data
rawDfr <- Init("DAA.04.txt")
# --- Count of raw data
nrow(rawDfr)
## [1] 40
# --- Names of header
names(rawDfr)
## [1] "training" "pre.uat" "post.uat" "gain"
# --- Create subsets of data for EACH group
wmDfr <- subset(rawDfr, rawDfr$training == "WM")
spDfr <- subset(rawDfr, rawDfr$training == "SP")
# --- Dependent t-test for SP group
t.test(spDfr$pre.uat, spDfr$post.uat, paired = T)
##
## Paired t-test
##
## data: spDfr$pre.uat and spDfr$post.uat
## t = -5.685, df = 19, p-value = 1.763e-05
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -31.47 -14.53
## sample estimates:
## mean of the differences
## -23
# --- Calculate effect size for dependent t-test (Cohen's d value) d =
# (Mean(X) - 0) / SD(X), pop mean = 0
spDescDfr <- describe(spDfr)
spDescDfr[4, 3]/spDescDfr[4, 4]
## [1] 1.271
# --- Dependent t-test for WM group
t.test(wmDfr$pre.uat, wmDfr$post.uat, paired = T)
##
## Paired t-test
##
## data: wmDfr$pre.uat and wmDfr$post.uat
## t = -4.199, df = 19, p-value = 0.0004863
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -28.47 -9.53
## sample estimates:
## mean of the differences
## -19
# --- Calculate effect size for dependent t-test (Cohen's d value) d =
# (Mean(X) - 0) / SD(X), pop mean = 0
wmDescDfr <- describe(wmDfr)
wmDescDfr[4, 3]/wmDescDfr[4, 4]
## [1] 0.9389
# --- Independent t-test
t.test(rawDfr$gain ~ rawDfr$training, var.equal = T)
##
## Two Sample t-test
##
## data: rawDfr$gain by rawDfr$training
## t = 0.659, df = 38, p-value = 0.5139
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -8.288 16.288
## sample estimates:
## mean in group SP mean in group WM
## 23 19
# --- Calculate effect size for independent t-test SD_Pooled ^ 2 =
# (DF_1/DF_Total) * SD_1 ^ 2 + (DF_2/DF_Total) * SD_2 ^ 2 d = (Mean(X_1) -
# Mean(X_2)) / SD_Pooled
sdPooledNum <- sqrt(19/38 * spDescDfr[4, 4]^2 + 19/38 * wmDescDfr[4, 4]^2)
(spDescDfr[4, 3] - wmDescDfr[4, 3])/sdPooledNum
## [1] 0.2084
#
# |------------------------------------------------------------------------------------------|
# | E N D O F S C R I P T |
# |------------------------------------------------------------------------------------------|