0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ウィルコクソンの符号順位検定

Last updated at Posted at 2017-05-06

対応のある2群のデータ

X=(x_1, x_2, x_3 \cdots x_n)\\
Y=(y_1, y_2, y_3 \cdots y_n)

について、二群間の代表値に違いがあるかどうか検定したい。
まず、二群間の差 $d_i = |x_i - y_i|$、差の符号 $s_i = sig(x_i - y_i)$をそれぞれ取る。
$d_i$を小さい順に並べたときの順位$r_i$を
$s_i > 0$である$i$について足し合わせて$R_{plus}$
$s_i < 0$である$i$について足し合わせて$R_{minus}$
とする。
統計量は$R=min(R_{plus}, R_{minx})$と表される。

$n'$($d_i=0$であるものを除いた要素数)が$n'=<25$のときは検定表から有意性検定を行う。

x <- c(1.83, 1.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30)
y <- c(0.88, 0.65, 0.60, 1.05, 1.06, 1.29, 1.06, 2.14, 1.29)
d <- x - y
s <- sign(d)
r <- rank(abs(d))
R_plus <- sum(r[which(s>0)])
R_minus <- sum(r[which(s<0)])
R <- min(R_plus, R_minus)
R

$n'>25$のとき

E(R)=\frac{n'(n'+1)}{4}\\
SD(R)=\sqrt{\frac{n'(n'+1)(2n'+1)}{24}}

とすると

z=\frac{R-E(R)}{SD(R)}

は標準正規分布に従うので、これによりp値を求める事ができる。

n <- sum(sign!=0)
mu <- n*(n+1)/4
sigma <- sqrt(n*(n+1)*(2*n+1)/24)
V <- abs(w-mu)/sigma
pnorm(V, lower=F)
wilcox.test(x, y, paired=T)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?