TestRankhist(rank.hist)
sum((x - sum(x)/length(x))^2 / (sum(x)/length(x)))
and has a chi^2 distribution with (length(x)-1) degrees of freedom if every rank is equally likely on average. The Jolliffe-Primo test statistics are calculated by projecting the vector
(x-sum(x)/length(x)) / sqrt(sum(x)/length(x))
onto a linear, respectively squared contrast, i.e. a linear and quadratic function defined over the index set 1:length(x), who are mutually orthogonal, whose elements sum to zero, and whose squared elements sum to one. The projections independently have chi^2 distributions with 1 degree of freedom under the null hypothesis of an asymptotically flat rank histogram.
Jolliffe I.T., Primo C. (2008): Evaluating rank histograms using decompositions of the chi-square test statistic. Mon. Wea. Rev. 136(6) DOI: 10.1175/2007MWR2219.1
# Example:
ens <- matrix(rnorm(500),100,5)
obs <- rnorm(100)
rh <- Rankhist(ens, obs)
TestRankhist(rh)
Run the code above in your browser using DataLab