Chapter 5, first part.

Tests for scale for two samples.


The following program finds the Ansari-Bradley statistic and it estimates the p-value of this test by doing simulations. I have used the data in page 147 from the textbook. I got that the statistic is 185.5 as in the textbook. I estimated the p-value of the test by doing 10,000 simulations. I got that the p-value is 0.9059, which is very close to the value in the textbook.
y_c(111,107,100,99,102,106,109,108,104,99,101,96,97,102,107,113,116,113,110,98)
x_c(107,108,106,98,105,103,110,105,104,100,96,108,103,104,114,114,113,108,106,99) 
m_length(x)
n_length(y)
N_m+n
xy_cbind(y,x)
rankxy_rank(xy)
rankxy_((N/2)-abs(rankxy-(N+1)/2))
rankxy_pmin(rankxy1,rankxy2)
ansari_0
for(i in 1:n) 
{
ansari_ansari+rankxy[i]
}

N_10000
zb1_c(1:N)
for(i in 1:N){
zb <- sample(rankxy,m,replace=F)
zb1[i]<-sum(zb)
}
zb2_(zb1>ansari)
pvalue_mean(zb2)
print(ansari)
print(pvalue)
> print(ansari)
[1] 185.5
> print(pvalue)
[1] 0.9059

Comments to: Miguel A. Arcones