よい検定、わるい検定
この二つの解説は非常に分かりやすい。
http://aoki2.si.gunma-u.ac.jp/lecture/BF/index.html
http://aoki2.si.gunma-u.ac.jp/lecture/BF/sankouzu.html
2群はwelchのt検定、3群はoneway.test(ANOVA(aov)はNG)が良いとのこと。なるほど。
一つ気になるのは、はずれ値があるとどうなるかということ。
そこでちょっと試してみた。はずれ値は発生する乱数の分布を参考に10,15,20,25を選んで、50の乱数に0個から3個加えて見た。
結果は、左からパラメトリックな検定、log変換後にパラメトリックな検定、ノンパラメトリックな検定の順に表示。
p < 0.05の割合なので、0.05に近い値が出ることが望ましい。
やはり期待した通り、パラメトリックな検定ははずれ値の影響を受けやすい。
(全く違うタイプの検定を比較することには意味がないかもしれないけど)無相関検定の方がより大きな影響がある。
先のサイトの解説を加味すると、2群の平均の差の検定ではlog変換した後にwelchのt検定が無難かなぁ。
無相関検定に関してはやはり、Spearmanを一番の候補にしておく方がよさそう。
n.samples <- 50 n.trials <- 10000 hist(rchisq(n.trials, 4)) outlier <- c(10,15,20,25) cat("Two sample test") for (n.rep in 0:3) { cat("----\n# of outliers:", n.rep, "\n") for (ol in outlier) { results <- matrix(NA, nrow=n.trials, ncol=3) for (i in 1:n.trials) { x <- c(rchisq(n.samples, 4), rep(4, n.rep)) y <- c(rchisq(n.samples, 4), ol+rnorm(n.rep)) results[i,] <- c(t.test(x, y)$p.value, t.test(log(x), log(y))$p.value, wilcox.test(x, y)$p.value) } cat("outlier:", ol, "\n") print(colSums(results<0.05)/n.trials) } } cat("Correlation test") for (n.rep in 0:3) { cat("----\n# of outliers:", n.rep, "\n") for (ol in outlier) { results <- matrix(NA, nrow=n.trials, ncol=3) for (i in 1:n.trials) { x <- c(rchisq(n.samples, 4), ol+rnorm(n.rep)) y <- c(rchisq(n.samples, 4), ol+rnorm(n.rep)) results[i,] <- c(cor.test(x, y, method="pearson")$p.value, cor.test(log(x), log(y), methodd="pearson")$p.value, cor.test(x, y, method="spearman")$p.value) } cat("outlier:", ol, "\n") print(colSums(results<0.05)/n.trials) } }
2群検定
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
無相関検定
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-