ad_stat {twosamples} | R Documentation |
Anderson-Darling Test
ad_stat(a, b, power = 2) ad_test(a, b, nboots = 2000, p = default.p)
a |
a vector of numbers |
b |
a vector of numbers |
power |
power to raise test stat to |
nboots |
Number of bootstrap iterations |
p |
power to raise test stat to |
The AD test compares two ECDFs by looking at the weighted sum of the squared differences between them – evaluated at each point in the joint sample. The weights are determined by the variance of the joint ECDF at that point. Formally – if E is the ECDF of sample 1, F is the ECDF of sample 2, and G is the ECDF of the joint sample then CVM = SUM_(x in k) (E(x)-F(x))^2/(G(x)*(1-G(x))) where k is the joint sample. The test p-value is calculated by randomly resampling two samples of the same size using the combined sample. Intuitively the AD test improves on the CVM test by giving lower weight to noisy observations.
Output is a length 2 Vector with test stat and p-value in that order. That vector has 3 attributes – the sample sizes of each sample, and the number of bootstraps performed for the pvalue.
ad_stat
: Anderson-Darling Test statistic
ad_test
: Permutation based two sample Anderson-Darling test
vec1 = rnorm(20) vec2 = rnorm(20,4) ad_test(vec1,vec2)