A psychologist conducts a study to determine whether or not noise can inhibit learning. Each of six subjects is tested under three experimental conditions. In each of the experimental conditions a subject is given 20 minutes to memorize a list of 10 nonsense syllables, which the subject is told she will be tested on the following day. The three experimental connditions each subject serves under are as follows: Condition 1, the no noise condition, requires subjects to study the list of nonsense syllables in a quiet room. Condition 2, the moderate noise condition, requires subjects to study the list of nonsense syllables while listening to classical music. Condition 3, the extreme noise condition, requires subjects to study the list of nonsense syllables while listening to rock music. Although in each of the experimental conditions subjects are presented with a different list of nonsense syllables, the three lists are comparable with respect to those variables that are known to influence a person’s ability to learn nonsense syllables. To control for order effects, the order of presentation of the three experimental conditions is completely counterbalanced. The number of nonsense syllables correctly recalled by the six subjects under the three experimental conditions follows: (Subjects’ scores are listed in the order Condition 1, Condition 2, Condition 3.)
library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.0 ✔ purrr 0.3.4
✔ tibble 3.1.8 ✔ dplyr 1.0.10
✔ tidyr 1.2.1 ✔ stringr 1.4.1
✔ readr 2.1.2 ✔ forcats 0.5.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
library(ggpubr)
library(rstatix)
Attaching package: 'rstatix'
The following object is masked from 'package:stats':
filter
library(readxl)
Friedman <- read_excel("D:/MARV BS MATH/4th year, 2nd sem/Nonparametric Statistics/Final Exam/Friedman.xlsx")
Friedman
# A tibble: 6 × 4
Subject Condition1 Condition2 Condition3
<dbl> <dbl> <dbl> <dbl>
1 1 9 7 4
2 2 10 8 7
3 3 7 5 3
4 4 10 8 7
5 5 7 5 2
6 6 8 6 6
ks.test(Friedman,"pnorm")
Warning in ks.test.default(Friedman, "pnorm"): ties should not be present for
the Kolmogorov-Smirnov test
Asymptotic one-sample Kolmogorov-Smirnov test
data: Friedman
D = 0.93558, p-value < 2.2e-16
alternative hypothesis: two-sided
Since the p-value 2.2e-16 is less than D = 0.84134, then we reject the null hypothesis and conclude that at least one value does not match the specifies distribution.
F <- Friedman %>%
gather(key = "Condition", value = "score", Condition1, Condition2, Condition3) %>%
convert_as_factor(Subject, Condition)
head(F, 6)
# A tibble: 6 × 3
Subject Condition score
<fct> <fct> <dbl>
1 1 Condition1 9
2 2 Condition1 10
3 3 Condition1 7
4 4 Condition1 10
5 5 Condition1 7
6 6 Condition1 8
summary(Friedman)
Subject Condition1 Condition2 Condition3
Min. :1.00 Min. : 7.00 Min. :5.00 Min. :2.000
1st Qu.:2.25 1st Qu.: 7.25 1st Qu.:5.25 1st Qu.:3.250
Median :3.50 Median : 8.50 Median :6.50 Median :5.000
Mean :3.50 Mean : 8.50 Mean :6.50 Mean :4.833
3rd Qu.:4.75 3rd Qu.: 9.75 3rd Qu.:7.75 3rd Qu.:6.750
Max. :6.00 Max. :10.00 Max. :8.00 Max. :7.000
ggboxplot(F, x = "Condition", y = "score", add = "jitter")
res.fried <- F %>% friedman_test(score ~ Condition |Subject)
res.fried
## # A tibble: 1 × 6
## .y. n statistic df p method
## * <chr> <int> <dbl> <dbl> <dbl> <chr>
## 1 score 6 11.6 2 0.00308 Friedman test
There was a statistically significant difference in inhibiting learning depending on which type of noise was upon the memorizing of nonsense syllable of the subject , χ2 = 11.56522, p = 0.003080668
F %>% friedman_effsize(score ~ Condition |Subject)
# A tibble: 1 × 5
.y. n effsize method magnitude
* <chr> <int> <dbl> <chr> <ord>
1 score 6 0.964 Kendall W large
A large effect size is detected, W = 0.9637681.
# pairwise comparisons
pwc <- F %>%
wilcox_test(score ~ Condition, paired = TRUE, p.adjust.method = "bonferroni")
pwc
# A tibble: 3 × 9
.y. group1 group2 n1 n2 statistic p p.adj p.adj.signif
* <chr> <chr> <chr> <int> <int> <dbl> <dbl> <dbl> <chr>
1 score Condition1 Condition2 6 6 21 0.02 0.059 ns
2 score Condition1 Condition3 6 6 21 0.035 0.105 ns
3 score Condition2 Condition3 6 6 15 0.057 0.17 ns
Condition1 and Condition2 are not statistically significant with p-value 0.059.
Condition1 and Condition3 are not statistically significant with p-value 0.105.
Condition2 and Condition3 are not statistically significant with p-value 0.170.
# Visualization: box plots with p-values
pwc <- pwc %>% add_xy_position(x = "Condition")
ggboxplot(F, x = "Condition", y = "score", add = "point") +
stat_pvalue_manual(pwc, hide.ns = TRUE) +
labs(
subtitle = get_test_label(res.fried, detailed = TRUE),
caption = get_pwc_label(pwc)
)
By the result presented above, the answer is affirmative.