Load R packages
### Here, you load the packages that are needed for your analyses
# please note that you first need to install these, as described in
# the "getting started with R"-guide before loading them here
library("rstatix") # for rmANOVA
##
## Vedhæfter pakke: 'rstatix'
## Det følgende objekt er maskeret fra 'package:stats':
##
## filter
library("psych") # for nice table of descriptive stats
Load data into R (opens open file dialog)
data_file <- rstudioapi::selectFile(caption = "Select the group data (VLTM-E202X_samlet.csv)",
filter = "CSV Files (*.csv)",
existing = TRUE)
VLTM_data <- read.csv(data_file, sep = ",")
Opgave: 1
# create a table of descriptive statistics
VLTM_descr <- describe(VLTM_data)
# display descriptives
VLTM_descr
## vars n mean sd median trimmed mad min
## FID 1 129 440.22 241.65 410.00 429.04 295.04 101.00
## Korrekthed_billeder 2 129 0.95 0.06 0.96 0.95 0.03 0.74
## Dprime_billeder 3 129 2.50 0.73 2.48 2.50 0.63 0.91
## Korrekthed_polygoner 4 129 0.57 0.07 0.58 0.57 0.06 0.38
## Dprime_polygoner 5 129 0.27 0.26 0.29 0.27 0.31 -0.43
## Korrekthed_tal 6 129 0.58 0.08 0.60 0.59 0.06 0.36
## Dprime_tal 7 129 0.31 0.29 0.36 0.31 0.22 -0.51
## Korrekthed_ord 8 129 0.85 0.10 0.86 0.85 0.12 0.60
## Dprime_ord 9 129 1.61 0.71 1.53 1.56 0.68 0.36
## Korrekthed_ord_konkret 10 127 0.85 0.12 0.88 0.86 0.12 0.44
## Dprime_ord_konkret 11 126 1.75 0.94 1.66 1.68 0.98 -0.21
## Korrekthed_ord_abstrakt 12 127 0.83 0.11 0.84 0.84 0.12 0.56
## Dprime_ord_abstrakt 13 127 1.56 0.79 1.41 1.50 0.86 0.21
## max range skew kurtosis se
## FID 908.00 807.00 0.31 -1.01 21.28
## Korrekthed_billeder 1.00 0.26 -1.60 2.66 0.00
## Dprime_billeder 4.37 3.46 0.19 0.14 0.06
## Korrekthed_polygoner 0.74 0.36 -0.09 -0.30 0.01
## Dprime_polygoner 0.91 1.34 0.01 -0.35 0.02
## Korrekthed_tal 0.76 0.40 -0.29 -0.17 0.01
## Dprime_tal 1.00 1.51 -0.16 -0.07 0.03
## Korrekthed_ord 1.00 0.40 -0.37 -0.86 0.01
## Dprime_ord 3.29 2.93 0.52 -0.57 0.06
## Korrekthed_ord_konkret 1.00 0.56 -0.74 0.07 0.01
## Dprime_ord_konkret 4.37 4.58 0.72 0.26 0.08
## Korrekthed_ord_abstrakt 1.00 0.44 -0.43 -0.66 0.01
## Dprime_ord_abstrakt 4.37 4.16 0.79 0.50 0.07
# Copy the relevant values into your table. There is a template on Absalon you can download and use for this.
Opgave: 2
# create a diagramme of accuracy across all four main conditions:
barplotACC <- barplot(
VLTM_descr$mean[c(2,4,6,8)], # use rows 2,4,6,8 of the table created in exercise 1
ylim=c(0,1), # set the figure limits on the y-axis to 0 (min) and 1 (max)
args.legend = list(x = "top", bty="n"),
ylab="Korrekthed (%)", # label for the y-axis
xlab = "Konditioner", # label for the x-axis
names.arg=c("Billeder", "Polygoner", "Tal", "Ord") # labels for the four conditions
)
# Add error bars
arrows(x0 = barplotACC,
y0 = VLTM_descr$mean[c(2,4,6,8)] + 2*VLTM_descr$se[c(2,4,6,8)], # upper error bar length
y1 = VLTM_descr$mean[c(2,4,6,8)] - 2*VLTM_descr$se[c(2,4,6,8)], # lower error bar length
angle = 90, # draw vertically
code = 3,
length = 0.1) # length of the "whiskers"

Opgave: 3
# create a diagramme of accuracy across word condition (concrete vs. abstact)
barplotACC_word <- barplot(VLTM_descr$mean[c(10,12)], # use rows 10 and 12 the table created in exercise 1
ylim=c(0,1.0), # set the figure limits on the y-axis to 0 (min) and 1 (max)
args.legend = list(x = "top", bty="n"),
ylab="Korrekthed (%)", # label for the y-axis
xlab = "Ordkondition", # label for the x-axis
names.arg=c("Konkrete ord", "Abstrakte ord") # labels for the two conditions
)
# Add error bars
arrows(x0 = barplotACC_word,
y0 = VLTM_descr$mean[c(10,12)] + 2*VLTM_descr$se[c(10,12)],
y1 = VLTM_descr$mean[c(10,12)] - 2*VLTM_descr$se[c(10,12)],
angle = 90,
code = 3,
length = 0.1
)

Opgave: 4
# run 4 t-tests to test if d-prime is significantly different from zero
# test for condition "pictures":
ttest_pictures <- t.test(VLTM_data$Dprime_billeder, mu=0)
# test for condition "polygons":
ttest_polygons <- t.test(VLTM_data$Dprime_polygoner, mu=0)
# test for condition "number":
ttest_numbers <- t.test(VLTM_data$Dprime_tal, mu= 0)
# test for condition "words":
ttest_words <- t.test(VLTM_data$Dprime_ord, mu= 0)
# display the test results
ttest_pictures
##
## One Sample t-test
##
## data: VLTM_data$Dprime_billeder
## t = 38.839, df = 128, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## 2.368653 2.622950
## sample estimates:
## mean of x
## 2.495801
ttest_polygons
##
## One Sample t-test
##
## data: VLTM_data$Dprime_polygoner
## t = 11.824, df = 128, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## 0.2262275 0.3171597
## sample estimates:
## mean of x
## 0.2716936
ttest_numbers
##
## One Sample t-test
##
## data: VLTM_data$Dprime_tal
## t = 12.029, df = 128, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## 0.2561159 0.3569663
## sample estimates:
## mean of x
## 0.3065411
ttest_words
##
## One Sample t-test
##
## data: VLTM_data$Dprime_ord
## t = 25.876, df = 128, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## 1.485911 1.731979
## sample estimates:
## mean of x
## 1.608945
# estimate effect sizes:
cohens_d_pictures <- mean(VLTM_data$Dprime_billeder)/sd(VLTM_data$Dprime_billeder)
cohens_d_polygons <- mean(VLTM_data$Dprime_polygoner)/sd(VLTM_data$Dprime_polygoner)
cohens_d_numbers <- mean(VLTM_data$Dprime_tal)/sd(VLTM_data$Dprime_tal)
cohens_d_words <- mean(VLTM_data$Dprime_ord)/sd(VLTM_data$Dprime_ord)
cohens_d_pictures
## [1] 3.419611
cohens_d_polygons
## [1] 1.041047
cohens_d_numbers
## [1] 1.059058
cohens_d_words
## [1] 2.278215
Opgave: 5
# run a repeated-measures ANOVA on d-prime to test, if any of the conditions is significantly different from the others
# first, transform data from wide to long format
n = VLTM_descr$n[1]
ncond = 4
VLTM_Dprime_long = data.frame(S=c(rep(1:n,ncond)), cond=rep(1:ncond, each=n), Dprime=c(VLTM_data$Dprime_billeder, VLTM_data$Dprime_polygoner, VLTM_data$Dprime_tal, VLTM_data$Dprime_ord))
VLTM_Dprime_long$cond = factor(VLTM_Dprime_long$cond)
# now, run an rmANOVA on the accuracy data
rmANOVA_Dprime = anova_test(
VLTM_Dprime_long, # the dataset to be used in the ANOVA
dv = Dprime, # the dependent variable (dv)
wid = S, # the subject identifier
within = cond, # the within subject variable (called cond(ition))
effect.size="pes"# request partial eta squared (pes) as effect size measure
)
# display the results of the ANOVA
get_anova_table(rmANOVA_Dprime)
## ANOVA Table (type III tests)
##
## Effect DFn DFd F p p<.05 pes
## 1 cond 2.36 302.22 596.48 4.51e-114 * 0.823
# Short explanation of the output:
# DFn is the number of degrees of freedom (DF) for the numerator (n) (dk: tæller)
# DFd is the number of degrees of freedom (DF) for the denominator (d) (dk: nævner)
# NB: both DFn and DFd are Greenhouse-Geisser-corrected!
# F is the test statistic
# p is the p-value
# pes is the effect size (partial eta squared)
Opgave: 6
# perform post-hoc tests between the four main condition. There are 4 conditions, that is, 6 post-hoc tests
# we compare performance within-subject, so we use "paired=TRUE" to perform a paired t-test
# test of performance in condition "pictures" vs. "polygons":
ttest_pictures_polygons <- t.test(VLTM_data$Dprime_billeder,VLTM_data$Dprime_polygoner, paired=TRUE)
# test of performance in condition "pictures" vs. "numbers":
ttest_pictures_numbers <- t.test(VLTM_data$Dprime_billeder,VLTM_data$Dprime_tal, paired=TRUE)
# test of performance in condition "pictures" vs. "words":
ttest_pictures_words <- t.test(VLTM_data$Dprime_billeder,VLTM_data$Dprime_ord, paired=TRUE)
# test of performance in condition "polygons" vs. "numbers":
ttest_polygons_numbers <- t.test(VLTM_data$Dprime_polygoner,VLTM_data$Dprime_tal, paired=TRUE)
# test of performance in condition "polygons" vs. "words":
ttest_polygon_words <- t.test(VLTM_data$Dprime_polygoner,VLTM_data$Dprime_ord, paired=TRUE)
# test of performance in condition "numbers" vs. "words":
ttest_numbers_words <- t.test(VLTM_data$Dprime_tal,VLTM_data$Dprime_ord, paired=TRUE)
# display results
ttest_pictures_polygons
##
## Paired t-test
##
## data: VLTM_data$Dprime_billeder and VLTM_data$Dprime_polygoner
## t = 32.364, df = 128, p-value < 2.2e-16
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## 2.088130 2.360086
## sample estimates:
## mean difference
## 2.224108
ttest_pictures_numbers
##
## Paired t-test
##
## data: VLTM_data$Dprime_billeder and VLTM_data$Dprime_tal
## t = 34.432, df = 128, p-value < 2.2e-16
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## 2.063453 2.315068
## sample estimates:
## mean difference
## 2.18926
ttest_pictures_words
##
## Paired t-test
##
## data: VLTM_data$Dprime_billeder and VLTM_data$Dprime_ord
## t = 12.203, df = 128, p-value < 2.2e-16
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## 0.7430535 1.0306596
## sample estimates:
## mean difference
## 0.8868565
ttest_polygons_numbers
##
## Paired t-test
##
## data: VLTM_data$Dprime_polygoner and VLTM_data$Dprime_tal
## t = -1.062, df = 128, p-value = 0.2902
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## -0.09977081 0.03007592
## sample estimates:
## mean difference
## -0.03484744
ttest_polygon_words
##
## Paired t-test
##
## data: VLTM_data$Dprime_polygoner and VLTM_data$Dprime_ord
## t = -20.319, df = 128, p-value < 2.2e-16
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## -1.467476 -1.207026
## sample estimates:
## mean difference
## -1.337251
ttest_numbers_words
##
## Paired t-test
##
## data: VLTM_data$Dprime_tal and VLTM_data$Dprime_ord
## t = -20.502, df = 128, p-value < 2.2e-16
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## -1.428098 -1.176710
## sample estimates:
## mean difference
## -1.302404
### estimate effect sizes for exercise 6:
# Cohens d for paired sampled t-test is the mean difference over the standard deviation of the difference:
cohensd_pictures_polygons <- abs(mean(VLTM_data$Dprime_billeder-VLTM_data$Dprime_polygoner))/sd(VLTM_data$Dprime_billeder-VLTM_data$Dprime_polygoner)
cohensd_pictures_numbers <- abs(mean(VLTM_data$Dprime_billeder-VLTM_data$Dprime_tal))/sd(VLTM_data$Dprime_billeder-VLTM_data$Dprime_tal)
cohensd_pictures_words <- abs(mean(VLTM_data$Dprime_billeder-VLTM_data$Dprime_ord))/sd(VLTM_data$Dprime_billeder-VLTM_data$Dprime_ord)
cohensd_polygons_numbers <- abs(mean(VLTM_data$Dprime_tal-VLTM_data$Dprime_polygoner))/sd(VLTM_data$Dprime_tal-VLTM_data$Dprime_polygoner)
cohensd_polygons_words <- abs(mean(VLTM_data$Dprime_ord-VLTM_data$Dprime_polygoner))/sd(VLTM_data$Dprime_ord-VLTM_data$Dprime_polygoner)
cohensd_numbers_words <- abs(mean(VLTM_data$Dprime_tal-VLTM_data$Dprime_ord))/sd(VLTM_data$Dprime_tal-VLTM_data$Dprime_ord)
# display results:
cohensd_pictures_polygons
## [1] 2.849483
cohensd_pictures_numbers
## [1] 3.031586
cohensd_pictures_words
## [1] 1.074395
cohensd_polygons_numbers
## [1] 0.09350796
cohensd_polygons_words
## [1] 1.788948
cohensd_numbers_words
## [1] 1.805134
Opgave: 7
# test for a possible concreteness effect; word condition only
ttest_concreteness <- t.test(VLTM_data$Dprime_ord_konkret,VLTM_data$Dprime_ord_abstrakt, paired=TRUE)
# display result:
ttest_concreteness
##
## Paired t-test
##
## data: VLTM_data$Dprime_ord_konkret and VLTM_data$Dprime_ord_abstrakt
## t = 2.6288, df = 125, p-value = 0.009644
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## 0.0467773 0.3317824
## sample estimates:
## mean difference
## 0.1892799
# effect size
cohensd_concreteness <- abs(mean(VLTM_data$Dprime_ord_konkret-VLTM_data$Dprime_ord_abstrakt, na.rm = TRUE))/sd(VLTM_data$Dprime_ord_konkret-VLTM_data$Dprime_ord_abstrakt, na.rm=TRUE)
cohensd_concreteness
## [1] 0.2341906