c("coin", "DescTools")
wants <- wants %in% rownames(installed.packages())
has <-if(any(!has)) install.packages(wants[!has])
kruskal.test()
c( 99, 131, 118, 112, 128, 136, 120, 107, 134, 122)
IQ1 <- c(134, 103, 127, 121, 139, 114, 121, 132)
IQ2 <- c(110, 123, 100, 131, 108, 114, 101, 128, 110)
IQ3 <- c(117, 125, 140, 109, 128, 137, 110, 138, 127, 141, 119, 148)
IQ4 <- c(length(IQ1), length(IQ2), length(IQ3), length(IQ4))
Nj <- data.frame(DV=c(IQ1, IQ2, IQ3, IQ4),
KWdf <-IV=factor(rep(1:4, Nj), labels=c("I", "II", "III", "IV")))
kruskal.test(DV ~ IV, data=KWdf)
Kruskal-Wallis rank sum test
data: DV by IV
Kruskal-Wallis chi-squared = 6.0595, df = 3, p-value = 0.1087
kruskal_test()
from package coin
library(coin)
kruskal_test(DV ~ IV, distribution=approximate(B=9999), data=KWdf)
Approximative Kruskal-Wallis Test
data: DV by IV (I, II, III, IV)
chi-squared = 6.0595, p-value = 0.1054
pairwise.wilcox.test(KWdf$DV, KWdf$IV, p.adjust.method="holm")
Pairwise comparisons using Wilcoxon rank sum test
data: KWdf$DV and KWdf$IV
I II III
II 0.97 - -
III 0.84 0.51 -
IV 0.84 0.97 0.16
P value adjustment method: holm
oneway_test(DV ~ IV, distribution=approximate(B=9999), data=KWdf)
Approximative K-Sample Permutation Test
data: DV by IV (I, II, III, IV)
maxT = 2.2056, p-value = 0.09511
set.seed(123)
4
P <- c(41, 37, 42, 40)
Nj <- rep(c(-1, 0, 1, 2), Nj)
muJ <- data.frame(IV=ordered(rep(LETTERS[1:P], Nj)),
JTdf <-DV=rnorm(sum(Nj), muJ, 7))
Using JonckheereTerpstraTest()
from package DescTools
.
library(DescTools)
JonckheereTerpstraTest(DV ~ IV, data=JTdf)
Jonckheere-Terpstra test
data: DV by IV
JT = 5256, p-value = 0.1609
alternative hypothesis: two.sided
library(coin)
kruskal_test(DV ~ IV, distribution=approximate(B=9999), data=JTdf)
Approximative Linear-by-Linear Association Test
data: DV by IV (A < B < C < D)
chi-squared = 1.9035, p-value = 0.1701
friedman.test()
5
N <- 4
P <- c(14, 13, 12, 11, 10)
DV1 <- c(11, 12, 13, 14, 15)
DV2 <- c(16, 15, 14, 13, 12)
DV3 <- c(13, 12, 11, 10, 9)
DV4 <- data.frame(id=factor(rep(1:N, times=P)),
Fdf <-DV=c(DV1, DV2, DV3, DV4),
IV=factor(rep(1:P, each=N),
labels=LETTERS[1:P]))
friedman.test(DV ~ IV | id, data=Fdf)
Friedman rank sum test
data: DV and IV and id
Friedman chi-squared = 8.2653, df = 3, p-value = 0.04084
friedman_test()
from package coin
friedman_test(DV ~ IV | id, distribution=approximate(B=9999), data=Fdf)
Approximative Friedman Test
data: DV by IV (A, B, C, D)
stratified by id
chi-squared = 8.2653, p-value = 0.0296
oneway_test(DV ~ IV | id, distribution=approximate(B=9999), data=Fdf)
Approximative K-Sample Permutation Test
data: DV by IV (A, B, C, D)
stratified by id
maxT = 2.0226, p-value = 0.1891
10
N <- 4
P <- rep(c(-1, 0, 1, 2), each=N)
muJ <- data.frame(id=factor(rep(1:N, times=P)),
Pdf <-DV=rnorm(N*P, muJ, 3),
IV=ordered(rep(LETTERS[1:P], each=N)))
Using PageTest()
from package DescTools
.
library(DescTools)
PageTest(DV ~ IV | id, data=Pdf)
Page test for ordered alternatives
data: DV and IV and id
L = 263, p-value = 0.08656
Using friedman_test()
from package coin
.
library(coin)
friedman_test(DV ~ IV | id, distribution=approximate(B=9999), data=Pdf)
Approximative Page Test
data: DV by
IV (A < B < C < D)
stratified by id
chi-squared = 2.028, p-value = 0.1735
try(detach(package:DescTools))
try(detach(package:coin))
try(detach(package:survival))
try(detach(package:splines))
R markdown - markdown - R code - all posts