How to calculate the Anderson Darling Test ?

9 views (last 30 days)
I want to test the goodness of fit of the model , so I use A-D test
I am using matlab 2012a
I got the function from an exchange file.
I try:
paramEsts = gevfit(data); %estimate parameter data 453*1 double
xgrid = linspace(-40,70,453);
pdfEst = gevcdf(xgrid,paramEsts(1),paramEsts(2),paramEsts(3));
xnew=[data pdfEst'] % 453*2 double
but i got an Error:
There must have at least two samples.
and sometimes
one or more samples have no observations.
How I can solve this problem, and calculate the p-value of A-D test?

Accepted Answer

Walter Roberson
Walter Roberson on 11 Nov 2015
"There must have at least two samples." would imply that your xnew does not have at least two rows in those cases.
For "one or more samples have no observations.": the second column of the input is expected to be the group number, which is expected to be a positive integer 1 through the number of groups. If there are any integers in the range 1 to floor(max(xnew(:,2)) which are not present in xnew(:,2) then you would receive this message.
The column 2 data that you are passing is the cdf you have calculated, which would seldom happen to be a positive integer. Neither of your columns appear to be grouping numbers.
Notice the description in the source comments:
% The Anderson-Darling k-sample test was introduced by Scholz and Stephens
% (1987) as a generalization of the two-sample Anderson-Darling test. It is
% a nonparametric statistical procedure, i.e., a rank test, and, thus,
% requires no assumptions other than that the samples are true independent
% random samples from their respective continuous populations (although
% provisions for tied observations are made). It tests the hypothesis that
% the populations from which two or more independent samples of data were
% drawn are identical.
This requires an input that tells it which population each sample is drawn from. The program uses column 2 of the data to hold that information.
Possibly you need a different test.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!