c("car", "coin")
wants <- wants %in% rownames(installed.packages())
has <-if(any(!has)) install.packages(wants[!has])
set.seed(123)
2
P <- c(50, 40)
Nj <- rnorm(Nj[1], mean=100, sd=15)
DV1 <- rnorm(Nj[2], mean=100, sd=13)
DV2 <- data.frame(DV=c(DV1, DV2),
varDf <-IV=factor(rep(1:P, Nj)))
boxplot(DV ~ IV, data=varDf)
stripchart(DV ~ IV, data=varDf, pch=16, vert=TRUE, add=TRUE)
var.test(DV1, DV2)
var.test(DV ~ IV, data=varDf)
F test to compare two variances
data: DV by IV
F = 1.5437, num df = 49, denom df = 39, p-value = 0.1632
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
0.8361247 2.7913772
sample estimates:
ratio of variances
1.543726
mood.test(DV ~ IV, alternative="greater", data=varDf)
Mood two-sample test of scale
data: DV by IV
Z = 1.8065, p-value = 0.03542
alternative hypothesis: greater
ansari.test(DV ~ IV, alternative="greater", exact=FALSE, data=varDf)
Ansari-Bradley test
data: DV by IV
AB = 1025, p-value = 0.02116
alternative hypothesis: true ratio of scales is greater than 1
library(coin)
ansari_test(DV ~ IV, alternative="greater", distribution="exact", data=varDf)
Exact Ansari-Bradley Test
data: DV by IV (1, 2)
Z = -2.0304, p-value = 0.02138
alternative hypothesis: true mu is less than 1
c(22, 18, 20)
Nj <- sum(Nj)
N <- length(Nj)
P <- data.frame(DV=sample(0:100, N, replace=TRUE),
levDf <-IV=factor(rep(1:P, Nj)))
boxplot(DV ~ IV, data=levDf)
stripchart(DV ~ IV, data=levDf, pch=20, vert=TRUE, add=TRUE)
library(car)
leveneTest(DV ~ IV, center=median, data=levDf)
Levene's Test for Homogeneity of Variance (center = median)
Df F value Pr(>F)
group 2 0.1456 0.8648
57
leveneTest(DV ~ IV, center=mean, data=levDf)
Levene's Test for Homogeneity of Variance (center = mean)
Df F value Pr(>F)
group 2 0.0961 0.9085
57
fligner.test(DV ~ IV, data=levDf)
Fligner-Killeen test of homogeneity of variances
data: DV by IV
Fligner-Killeen:med chi-squared = 0.0936, df = 2, p-value = 0.9543
library(coin)
fligner_test(DV ~ IV, distribution=approximate(B=9999), data=levDf)
Approximative Fligner-Killeen Test
data: DV by IV (1, 2, 3)
chi-squared = 0.0936, p-value = 0.9586
try(detach(package:car))
try(detach(package:coin))
try(detach(package:survival))
try(detach(package:splines))
R markdown - markdown - R code - all posts