Last active
September 18, 2020 14:30
-
-
Save huberflores/b288092a99c02beb7ca7b0addb178cd7 to your computer and use it in GitHub Desktop.
Statistical test analysis, Friedman and Pairwise Wilcoxon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
suppressWarnings(library(tidyverse)) | |
suppressWarnings(library(ggpubr)) | |
suppressWarnings(library(rstatix)) | |
mydata <- read.csv("mydata-fixedhold.csv", sep=",", header = T) | |
myvars <- c("id", "cigarette", "bottle", "cup") | |
newdata <- mydata[myvars] | |
touch <- newdata %>% | |
gather(key = "material", value = "fading", cigarette, bottle, cup) %>% | |
convert_as_factor(id, material) | |
#head(touch, 20) | |
touch %>% | |
group_by(material) %>% | |
get_summary_stats(fading, type = "common") | |
ggboxplot(touch, x = "material", y = "fading", add = "jitter") | |
res.fried <- touch %>% friedman_test(fading ~ material |id) | |
res.fried | |
#X2(2) = 20.63, p = 0.000033106. | |
#Effect | |
#Kendall’s W uses the Cohen’s interpretation guidelines of 0.1 - < 0.3 (small effect), 0.3 - < 0.5 (moderate effect) and >= 0.5 (large effect). | |
touch %>% friedman_effsize(fading ~ material |id) | |
# W=0.54, magnitude = large effect | |
# pairwise comparisons | |
#A significant Friedman test can be followed up by pairwise Wilcoxon signed-rank tests for identifying which groups are different. | |
pwc <- touch %>% | |
wilcox_test(fading ~ material, paired = TRUE, p.adjust.method = "bonferroni") | |
pwc | |
pwc <- pwc %>% add_xy_position(x = "material") | |
ggboxplot(touch, x = "material", y = "fading", add = "point") + | |
stat_pvalue_manual(pwc, hide.ns = TRUE) + | |
labs( | |
subtitle = get_test_label(res.fried, detailed = TRUE), | |
caption = get_pwc_label(pwc) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment