Brown-Forsythe 検定 Last modified: Apr 08, 2015
目的
Brown-Forsythe 検定を行う。
普通は,R にも用意されている Bartlett.test 関数を使う方がよいと思われる。
使用法
Brown.Forsythe.test(x, group)
引数
x 分析対象となる観察値のベクトル
group 観察値がどの群に属するかを表すベクトル
ソース
インストールは,以下の 1 行をコピーし,R コンソールにペーストする
source("http://aoki2.si.gunma-u.ac.jp/R/src/Brown-Forsythe-test.R", encoding="euc-jp")
Brown.Forsythe.test <- function(x, group) { # x: データベクトル,group: 群変数ベクトル
data.name <- paste(deparse(substitute(x)), "~", deparse(substitute(group)))
OK <- complete.cases(x, group) # 欠損値を持つケースを除く
x <- x[OK]
group <- as.factor(group[OK])
group <- group[, drop=TRUE]
d <- split(x, group)
df1 <- length(d)-1
ni <- sapply(d, length)
mi <- sapply(d, mean)
ui <- sapply(d, var)
ci <- (1-ni/sum(ni))*ui
F.BF <- sum(ni*(mi-mean(x))^2)/sum(ci)
C <- ci/sum(ci)
df2 <- 1/sum(C^2/(ni-1))
p <- pf(F.BF, df1, df2, lower.tail=FALSE)
method <- "Brown-Forsythe 検定"
return(structure(list(statistic=c(F=F.BF), parameter=c("df1"=df1, "df2"=df2), "p.value"=p, method=method, data.name=data.name), class="htest"))
}
使用例
> x <- c(3, 3, 4, 2, 5, 2, 3, 4, 8, 8, 5, 6)
> g <- factor(rep(1:3, each=4))
> Brown.Forsythe.test(x, g)
Brown-Forsythe 検定
data: x ~ g
F = 10.8545, df1 = 2.000, df2 = 7.607, p-value = 0.00591
参考文献
1) Mehmet Mendes and Akin Pala: Evaluation of Four Tests
When Normality and Homogeneity of Variance Assumptions
are Violated, Journal of Applied Sciences 4(1): 38-42, 2004.
2) Brown, M. B., and A. B. Forsythe: The small sample
behavior of some statistics which test the equality of
several means., Technometrics, 16: 129-132, 1974.
直前のページへ戻る
E-mail to Shigenobu AOKI