Last active
April 29, 2022 18:42
-
-
Save StefanThoma/8e22e537aa779e6d106eea2f287501c1 to your computer and use it in GitHub Desktop.
Example of critical p-values for three basic multiple testing adjustments.
This file contains 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
library(tidyverse, jmv, ggplot2) | |
library(ggthemes) | |
data <- read_csv(file = "https://raw.githubusercontent.com/methodenlehre/data/master/alkohol-aggression.csv") %>% | |
mutate(alkoholbedingung = factor(alkoholbedingung, | |
levels = c("kein_alkohol", "placebo", "anti_placebo", "alkohol"))) | |
# 2. ANOVA inkl. Post-hoc Tests und Helmert-Kontrasten mit jamovi-Syntax | |
jmv_res <- jmv::ANOVA( | |
formula = aggressivitaet ~ alkoholbedingung, | |
data = data, | |
effectSize = c("eta", "omega"), | |
homo = TRUE, | |
contrasts = list( | |
list( | |
var="alkoholbedingung", | |
type="helmert")), | |
postHoc = ~ alkoholbedingung, | |
postHocCorr = c("tukey", "none", "bonf", "holm"), | |
emMeans = ~ alkoholbedingung, | |
emmPlotData = TRUE, | |
emmPlotError = "se", | |
emmTables = TRUE, | |
emmWeights = FALSE) | |
# Tabelle extrahieren | |
res_table <- as_data_frame(jmv_res$postHoc[[1]]$asDF) | |
alpha <- 0.05 | |
res_tab <- res_table %>% arrange(pnone) %>% # Tabelle nach p-Werten sortieren | |
mutate(order = 1:n(), | |
revorder = n():1, | |
pkrit_holm = alpha / revorder, | |
pkrit_bon = alpha / max(revorder), | |
pkrit_sidak = 1 - (1 - alpha)^(1/max(revorder))) %>% | |
select(order, pnone, starts_with("pkrit")) %>% | |
pivot_longer(cols = pkrit_holm:pkrit_sidak, names_to = "pkrit") # wide to long | |
# plotten | |
ggplot(data = res_tab, aes(x = order, y = pnone, col = pkrit)) + | |
facet_grid(~pkrit) + | |
geom_point() + | |
geom_line(aes(y = value)) + | |
theme_tufte() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment