library(tidyverse)
affective <- read.csv("affective filter hypothesis.csv")
head(affective)
## subject without_snacks with_snacks difference_snacks without_img with_img
## 1 1 80 86 6 72 85
## 2 2 85 90 5 92 95
## 3 3 80 81 1 84 93
## 4 4 77 91 14 87 97
## 5 5 77 86 9 89 96
## 6 6 65 84 19 70 79
## difference_img without_group with_group difference_group
## 1 13 75 86 11
## 2 3 88 92 4
## 3 9 60 71 11
## 4 10 84 91 7
## 5 7 69 86 17
## 6 9 72 84 12
Whether is there significant difference between with and without snacks group.
boxplot(affective$without_snacks, affective$with_snacks, names = c("without_snacks", "with_snacks"))
d <- density(affective$without_snacks)
d2 <- density(affective$with_snacks)
plot(d, col="red", xlim=c(0,150), ylim=c(0.0,0.05))
lines(d2, col="blue")
## This shows a lot of overlap, so we want to do a paired t-test.
We check to see whether the differences between the scores are normally distributed. To do this, we first need to make a vector of those differences:
## The differences between the pairs of scores shoule be normally distributed. So we should check that
shapiro.test(affective$difference_snacks)
##
## Shapiro-Wilk normality test
##
## data: affective$difference_snacks
## W = 0.94078, p-value = 0.6188
t.test(affective$without_snacks, affective$with_snacks, paired = TRUE)
##
## Paired t-test
##
## data: affective$without_snacks and affective$with_snacks
## t = -4.4096, df = 7, p-value = 0.00312
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## -15.362464 -4.637536
## sample estimates:
## mean difference
## -10
In the result above : t is the t-test statistic value (t = -4.4096), df is the degrees of freedom (df= 7), p-value is the significance level of the t-test (p-value = 0.00312). 95% confidence interval is also shown (conf.int= [-15.362464, -4.637536]) sample estimates is the mean differences between pairs (mean = -10).
boxplot(affective$without_img, affective$with_img, names = c("without_img", "with_img"))
d <- density(affective$without_img)
d2 <- density(affective$with_img)
plot(d, col="red", xlim=c(30,120), ylim=c(0.0,0.05))
lines(d2, col="blue")
## The differences between the pairs of scores shoule be normally distributed. So we should check that
shapiro.test(affective$difference_img)
##
## Shapiro-Wilk normality test
##
## data: affective$difference_img
## W = 0.92844, p-value = 0.502
t.test(affective$without_img, affective$with_img, paired = TRUE)
##
## Paired t-test
##
## data: affective$without_img and affective$with_img
## t = -4.0683, df = 7, p-value = 0.00476
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## -14.62641 -3.87359
## sample estimates:
## mean difference
## -9.25
boxplot(affective$without_group, affective$with_group, names = c("without_group", "with_group"))
d <- density(affective$without_group)
d2 <- density(affective$with_group)
plot(d, col="red", xlim=c(20,120), ylim=c(0.0,0.05))
lines(d2, col="blue")
## The differences between the pairs of scores shoule be normally distributed. So we should check that
shapiro.test(affective$difference_group)
##
## Shapiro-Wilk normality test
##
## data: affective$difference_group
## W = 0.9321, p-value = 0.5354
t.test(affective$without_group, affective$with_group, paired = TRUE)
##
## Paired t-test
##
## data: affective$without_group and affective$with_group
## t = -2.8628, df = 7, p-value = 0.02424
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## -13.010111 -1.239889
## sample estimates:
## mean difference
## -7.125