Memuat
Memuat
Nonparametric Tests (Mann-Whitney and Kruskal-Wallis) for Education and Learning
0 views
Comparing participation score across grade level groups with Mann-Whitney and Kruskal-Wallis tests and Spearman correlation with weekly reading hours, illustrated with synthetic data. Nonparametric tests compare distributions or medians across groups without assuming normality: Kruskal-Wallis for three or more groups, Mann-Whitney for two groups, plus Spearman rank correlation. They suit theses with ordinal scores, Likert scales, small samples or heavily skewed data.

Comparing participation score across grade level groups with Mann-Whitney and Kruskal-Wallis tests and Spearman correlation with weekly reading hours, illustrated with synthetic data.
| Role | Variable | Unit |
|---|---|---|
| Main | Participation score | score |
| Supporting 1 | Grade level | group |
| Supporting 2 | Weekly reading hours | hours |
Kruskal-Wallis shows that Participation score differs significantly across Grade level groups (H = 46.31, p < 0.001, epsilon2 = 0.126). Mann-Whitney between Grade 12 and Grade 10 is significant (p < 0.001) with a medium effect (r = 0.41). The Spearman correlation of Participation score with Weekly reading hours is 0.45 (p < 0.001).
Computed from illustrative synthetic data, not from a real study.
Nonparametric tests compare distributions or medians across groups without assuming normality: Kruskal-Wallis for three or more groups, Mann-Whitney for two groups, plus Spearman rank correlation. They suit theses with ordinal scores, Likert scales, small samples or heavily skewed data.
Report the Kruskal-Wallis H, degrees of freedom, p-value and epsilon squared, then the pairs that differ in the corrected pairwise Wilcoxon tests. For Mann-Whitney report W, p and r (0.1 small, 0.3 medium, 0.5 large), and the Spearman rho with its p-value.
A short starting script with this project's variable names. The delivered version is adapted to your data and fully commented.
# Contoh kode R: Nonparametric Tests (Mann-Whitney and Kruskal-Wallis)
suppressPackageStartupMessages({
library(ggplot2)
library(patchwork)
library(scales)
})
set.seed(42)
# ---- Gaya grafik ----
pal <- c("#1f6feb", "#e8590c", "#2f9e44", "#ae3ec9", "#f59f00")
warna <- list(bg = "#f4f6fa", panel = "#ffffff", teks = "#1f2933", redup = "#5f6b78", grid = "#e3e8ee", bar = "#1d3557")
tata <- 1
theme_set(theme_minimal(base_size = 11) + theme(legend.position = "bottom"))
# ---- Data sintetis: skor menceng pada tiga kelompok + satu variabel kontinu ----
n <- 200
lv <- c("A", "B", "C")
d <- data.frame(grade_level = factor(sample(rep(lv, length.out = n)), levels = lv),
weekly_reading_hours = round(pmax(rnorm(n, 30, 6), 0), 2))
z2 <- as.numeric(scale(d$weekly_reading_hours))
efek <- c(0, runif(1, 0.3, 0.6), runif(1, 0.6, 1.1))[sample(3)] # pergeseran lokasi antarkelompok (dalam SD)
bentuk <- runif(1, 1.5, 3)
galat <- (rgamma(n, shape = bentuk) - bentuk) / sqrt(bentuk) # galat menceng kanan
z <- efek[as.integer(d$grade_level)] - mean(efek) + runif(1, 0.25, 0.5) * z2 + galat * runif(1, 0.7, 0.9)
d$participation_score <- pmax(100 + 15 * z, 0)
d$participation_score <- if (15 >= 3) round(d$participation_score) else round(d$participation_score, 2) # skor bulat bila skalanya lebar
write.csv(d, "data_contoh.csv", row.names = FALSE)
# ---- Pemeriksaan normalitas (alasan memakai uji nonparametrik) ----
sw <- tapply(d$participation_score, d$grade_level, function(v) shapiro.test(v)$p.value)
print(sw)
print(aggregate(participation_score ~ grade_level, data = d, FUN = function(v) c(median = median(v), IQR = IQR(v), n = length(v))))
# ---- Kruskal-Wallis + ukuran efek epsilon kuadrat ----
kw <- kruskal.test(participation_score ~ grade_level, data = d)
print(kw)
eps2 <- unname(kw$statistic) / (nrow(d) - 1)
# ---- Perbandingan berpasangan Wilcoxon (koreksi Holm) ----
pw <- pairwise.wilcox.test(d$participation_score, d$grade_level, p.adjust.method = "holm", exact = FALSE)
print(pw)
# ---- Mann-Whitney: dua kelompok dengan median paling jauh + ukuran efek r ----
med <- tapply(d$participation_score, d$grade_level, median)
ekstrem <- names(c(which.min(med), which.max(med)))
if (ekstrem[1] == ekstrem[2]) ekstrem <- lv[c(1, 3)]
sub <- droplevels(d[d$grade_level %in% ekstrem, ])
mw <- wilcox.test(participation_score ~ grade_level, data = sub, exact = FALSE)
print(mw)
z_mw <- qnorm(mw$p.value / 2)
r_mw <- abs(z_mw) / sqrt(nrow(sub))
# ---- Korelasi peringkat Spearman ----
sp <- cor.test(d$participation_score, d$weekly_reading_hours, method = "spearman", exact = FALSE)
print(sp)
# ---- Grafik ----
bungkus <- scales::label_wrap(12)
pendek <- function(s, w = 12) ifelse(nchar(s) > w, paste0(trimws(substr(s, 1, w - 1)), "."), s)
dmed <- data.frame(grade_level = factor(names(med), levels = lv), median = as.numeric(med))
p1 <- ggplot(d, aes(grade_level, participation_score)) +
geom_violin(aes(fill = grade_level), alpha = 0.3, colour = NA, trim = TRUE) +
geom_boxplot(width = 0.18, outlier.size = 0.8, colour = warna$redup, fill = warna$panel, alpha = 0.8) +
geom_point(data = dmed, aes(y = median), shape = 21, size = 3, fill = pal[2], colour = warna$teks) +
scale_fill_manual(values = pal[c(1, 3, 4)], guide = "none") +
scale_x_discrete(labels = bungkus) +
labs(title = "Distribution by group (dot = median)", x = NULL, y = "participation_score")
mp <- matrix(NA_real_, 3, 3, dimnames = list(lv, lv))
mp[rownames(pw$p.value), colnames(pw$p.value)] <- pw$p.value
mp[upper.tri(mp)] <- t(mp)[upper.tri(mp)]
dp <- expand.grid(a = 1:3, b = 1:3)
dp$p <- mp[cbind(dp$a, dp$b)]
dp$teks <- ifelse(is.na(dp$p), "-", ifelse(dp$p < 0.001, "<0.001", sprintf("%.3f", dp$p)))
dp$skor <- ifelse(is.na(dp$p), NA, pmin(-log10(dp$p), 6))
dp$a <- factor(pendek(lv)[dp$a], levels = pendek(lv)); dp$b <- factor(pendek(lv)[dp$b], levels = rev(pendek(lv)))
p2 <- ggplot(dp, aes(a, b, fill = skor)) +
geom_tile(colour = warna$panel, linewidth = 1.2) +
geom_label(aes(label = teks), fill = warna$panel, colour = warna$teks, size = 3.2, label.size = 0, alpha = 0.85) +
scale_fill_gradient(low = warna$grid, high = pal[2], na.value = warna$panel, limits = c(0, 6), guide = "none") +
scale_x_discrete(labels = bungkus) + scale_y_discrete(labels = bungkus) +
labs(title = "Pairwise Wilcoxon p-values (Holm)", x = NULL, y = NULL) +
theme(panel.grid = element_blank())
dr <- data.frame(ry = rank(d$participation_score), rx = rank(d$weekly_reading_hours), kelompok = d$grade_level)
p3 <- ggplot(dr, aes(rx, ry)) +
geom_point(aes(colour = kelompok), alpha = 0.55, size = 1.4) +
geom_smooth(method = "lm", formula = y ~ x, colour = warna$teks, fill = warna$redup, alpha = 0.2, linewidth = 1) +
scale_colour_manual(values = pal[c(1, 3, 4)], name = NULL, labels = pendek) +
labs(title = sprintf("Spearman rank scatter (rho = %.2f)", sp$estimate), x = "Rank of weekly_reading_hours", y = "Rank of participation_score") +
theme(legend.position = "bottom")
p_hasil <- if (tata == 1) p1 | (p2 / p3) else (p2 / p3) | p1
print(p_hasil)
The original project file is available. It is not just the picture above: you get the working R project. It can be downloaded after payment, and we send it by WhatsApp or email.
ZIP: analisis.R + data_contoh.csv + BACA-DULU.txt
Choose how much help you need. Each higher package includes everything in the lower ones. Prices exclude 11% VAT.
Package 1
US$16
excl. 11% VAT
Duration: 3 working days
Output: R files + result figures
Deliverables
Package 2 · most chosen
US$47
excl. 11% VAT
Duration: 7 working days
Output: Code + analysis + interpretation notes
Includes all of Package 1, plus
Package 3
US$103
excl. 11% VAT
Duration: 12-15 working days
Output: Code + analysis + guidance until ready to present
Includes all of Packages 1 & 2, plus
Yes. The original project file is a ZIP containing the complete analisis.R script, a data_contoh.csv sample dataset and a BACA-DULU.txt guide. It can be downloaded after payment, and we send it by WhatsApp or email. For your own data (Package 2 and 3) the script is adapted to your dataset.
Yes. Nonparametric Tests (Mann-Whitney and Kruskal-Wallis) is commonly used at this level in Education and Learning. We adapt the analysis to your research question, your own data and your supervisor's requirements.
No. The sheet is computed from illustrative synthetic data so you can see the kind of output R Studio gives. For your order we run the same method on your own data.
That is the point of the packages. Every script is commented, and Package 3 includes two coaching sessions plus practice questions so you can explain the method and the results at your seminar and defence.
Each project has three packages: Package 1 (code and explanation) US$16, Package 2 (your data analysis and interpretation) US$47 and Package 3 (full guidance) US$103, excluding 11% VAT. Larger datasets, extra methods or tight deadlines adjust the quote after a short consultation.
The result sheet uses illustrative synthetic data. R is a programming language of the R Foundation project; RStudio and Posit are trademarks of Posit PBC.
Back to R Studio portfolio