0% found this document useful (0 votes)
20 views10 pages

Chap8

The document discusses permutation tests for assessing differences between distributions. It covers the permutation distribution and tests for equal distributions such as the Kolmogorov-Smirnov test. An example compares soybean and linseed feed weights for chickens using a permutation test and the Kolmogorov-Smirnov test.

Uploaded by

shuhuifang2023
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views10 pages

Chap8

The document discusses permutation tests for assessing differences between distributions. It covers the permutation distribution and tests for equal distributions such as the Kolmogorov-Smirnov test. An example compares soybean and linseed feed weights for chickens using a permutation test and the Kolmogorov-Smirnov test.

Uploaded by

shuhuifang2023
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Chapter 8: ˜†u

Contents

1 Permutation Tests 1
1.1 Permutation Distribution . . . . . . . . . . . . . . . . . . . 2
1.2 Tests for Equal Distributions . . . . . . . . . . . . . . . . . 6

Previous Next First Last Back Forward 1


Chapter 1
Permutation Tests

˜†u, ÄuØ£­Ä, Ï~Ššëêu, u


H0 : F = G vs H1 : F ̸= G, (1.1)

Ù¥F ÚG´ü‡™©Ù. ·‚̇?Øù«œ¹.


Œ±u
H0 : FX,Y = FX FY vs H1 : FX,Y ̸= FX FY ,

Ú
H0 : F1 = · · · = Fk vs H1 : Fi ̸= Fj for some i, j.

Previous Next First Last Back Forward 1


1.1 Permutation Distribution

˜†uÚ½:
1. OŽ*ÿÚOþ θ̂(X, Y ) = θ̂(Z, ν).

2. ­ÄB g, Pb = 1, . . . , B;

(a) ‘Å)¤˜‡˜†π = π(ν). b

(b) OŽÚOþθ̂ (b) ∗


= θ̂ (Z, π ). b

3. XJŒθ̂|±Jb, OŽ˜&Y²
∑B
1 + #{θ̂b ≥ θ̂} 1+ I{θ̂b ≥ θ̂}
b=1
p̂ = = .
B+1 B+1

Œ±±aqªOކ>½öV>up̂.
4. XJp̂ ≤ α, K3wÍ5Y²αeáýbH . 0

Previous Next First Last Back Forward 2


~8.1: ÚOþ˜†©Ù
·‚^ R ¥ chickwts data, Tê⥝¹fÈzÑ/N­, ±Ž
ü , /d8«ØÓ ÔÖ¿ž. Œ±^
↑Code
boxplot( formula(chickwts) )
↓Code

xãwÑêâŒNA, l㥌±uy, soybean |Ú linseed |/


N­k:aq.
↑Code
attach(chickwts)
x <- sort(as.vector(weight[feed == "soybean"]))
y <- sort(as.vector(weight[feed == "linseed"]))
detach(chickwts)
↓Code

üS ü/N­
Previous Next First Last Back Forward 3
X: 158 171 193 199 230 243 248 248 250 267 271 316 327 329
Y: 141 148 169 181 203 213 229 244 257 260 271 309

·‚Œ±ÏLOŽü‡ƒmålÚOþ5'ü|, ~X^ü
 T ÚOþ. , , ü|©Ù™. ·‚Œ±ÏL˜†©ÙOŽ T wÍ
5Y².
5¿þ n = 14, m = 12, ¤±k
(n + m ) (26) 26!
= = = 9, 657, 700
n 14 14!12!
¥ØÓ˜†. =¦éuù«êâ, Ĥk˜†´Øy
¢, ·‚ÄCq˜†©Ù. Cq˜†uŒ±^Xe“è:
↑Code
R <- 999 #number of replicates
z <- c(x, y) #pooled sample
K <- 1:26
reps <- numeric(R) #storage for replicates
t0 <- t.test(x, y)$statistic

Previous Next First Last Back Forward 4


for (i in 1:R) {
#generate indices k for the first sample
k <- sample(K, size = 14, replace = FALSE)
x1 <- z[k]
y1 <- z[-k] #complement of x1
reps[i] <- t.test(x1, y1)$statistic
}
p <- mean(c(t0, reps) >= t0)
> p
[1] 0.101
↓Code

ùp p̂ Ž´)¤ T Œuu*ÿÚOþ T '~. éuV—u, w



0

Í5Y²AT´ 2p̂, XJ p̂ ≤ 0.5; 2(1 − p̂) XJ p̂ > 0.5. ¤±ù‡~f¥


 p Š 0.202. Xe†ãŒ±Ð«ìC˜†©Ù:
↑Code
hist(reps, main = "", freq = FALSE, xlab = "T (p = 0.202)",
breaks = "scott")
points(t0, 0, cex = 1, pch = 16) #observed T

Previous Next First Last Back Forward 5


↓Code

1.2 Tests for Equal Distributions

 ¦^˜†uuü‡©Ù´ÄƒÓ, ·‚Œ±ÀJÝþü‡©Ùƒm
ÉÚOþ, ~X Kolmogorov-Smirnov (K-S) ÚOþ, ½ö˜‘œ¹eü
 Cramer-von Mises ÚOþ.
~8.2: K-S ÚOþ˜†©Ù
Äbu¯K H : F = G vs H : F ̸= G. K-S ÚOþ/ª
0 1

D= sup |Fn (zi ) − Gm (zi )|,


1≤i≤N

Ù¥ F ´ x , . . . , x ²©Ù¼ê, G ´ y , . . . , y ²©Ù¼ê.
n 1 n m 1 m

5¿ 0 ≤ D ≤ 1, ¿ Œ D Š|±Jb F ̸= G.
↑Code
Previous Next First Last Back Forward 6
R <- 999 #number of replicates
z <- c(x, y) #pooled sample
K <- 1:26
D <- numeric(R) #storage for replicates
options(warn = -1)
D0 <- ks.test(x, y, exact = FALSE)$statistic
for (i in 1:R) {
#generate indices k for the first sample
k <- sample(K, size = 14, replace = FALSE)
x1 <- z[k]
y1 <- z[-k] #complement of x1
D[i] <- ks.test(x1, y1, exact = FALSE)$statistic
}
p <- mean(c(D0, D) >= D0)
options(warn = 0)
> p
[1] 0.46
↓Code

wÍ5Y² 0.46 ¿Ø|±Jb. Ä)¤ D †ãŒ±^


Xe“èL«:
Previous Next First Last Back Forward 7
↑Code
hist(D, main = "", freq = FALSE, xlab = "D (p = 0.46)",
breaks = "scott")
points(D0, 0, cex = 1, pch = 16) #observed D
↓Code

Previous Next First Last Back Forward 8

You might also like