SO.trend.test {CorrBin}  R Documentation 
Performs a likelihood ratio test of stochastic ordering versus equality using
permutations to estimate the nulldistribution and the pvalue. If only the
value of the test statistic is needed, use SO.LRT
instead.
SO.trend.test(cbdata, R = 100, control = soControl())
cbdata 
a 
R 
an integer – the number of random permutations for estimating the null distribution. 
control 
an optional list of control settings, usually a call to

The test is valid only under the assumption that the clustersize distribution does not depend on group. During the estimation of the nulldistribution the group assignments of the clusters are permuted keeping the group sizes constant; the withingroup distribution of the clustersizes will vary randomly during the permutation test.
The default value of R
is probably too low for the final data
analysis, and should be increased.
A list with the following components
LRT 
the value of the likelihood ratio test statistic. It has two
attributes: 
p.val 
the estimated onesided pvalue. 
boot.res 
an object of class "boot" with the detailed results of
the permutations. See 
Aniko Szabo, aszabo@mcw.edu
Szabo A, George EO. (2009) On the Use of Stochastic Ordering to Test for Trend with Clustered Binary Data.
SO.LRT
for calculating only the test statistic,
soControl
data(shelltox)
set.seed(45742)
sh.test < SO.trend.test(shelltox, R=5, control=soControl(eps=0.1, max.directions=25))
sh.test
#a plot of the resampled LRT values
#would look better with a reasonable value of R
null.vals < sh.test$boot.res$t[,1]
hist(null.vals, breaks=10, freq=FALSE, xlab="Test statistic", ylab="Density",
main="Simulated nulldistribution", xlim=range(c(0,20,null.vals)))
points(sh.test$LRT, 0, pch="*",col="red", cex=3)