Skip to content

Source of Anderson-Darling statistic formulas? #2505

Open

Description

@anntzer

It would be nice if the source of the Anderson-Darling approximations formulas was documented.
Thanks.

Activity

  1. added this to the 0.8 milestone on Jul 6, 2015
  2. josef-pkt commented on Jul 6, 2015

    @josef-pkt
    Member

    I agree, without comments I also don't remember.
    The main basis for this and similar gof tests where several articles by Stephens
    https://en.wikipedia.org/wiki/Anderson%E2%80%93Darling_test

    most likely the 1986 chapter, but that is in large parts a summary of earlier articles.

  3. anntzer commented on Jul 6, 2015

    @anntzer
    ContributorAuthor

    FWIW there are quite a few implementations of Anderson-Darling available, giving different results:

    import numpy as np
    from statsmodels.stats.diagnostic import normal_ad as statsmodels_ad
    from scipy.stats import anderson as scipy_ad
    from anderson_darling import anderson_darling_normal as kuiper_ad
    import matlab.engine; eng = matlab.engine.start_matlab()
    from rpy2.robjects import FloatVector
    from rpy2.robjects.packages import importr
    
    
    N = 8
    print("statsmodels (stat, pval)\n",
          statsmodels_ad(np.arange(N)), "\n")
    print("scipy\n",
          scipy_ad(np.arange(N)), "\n")
    print("kuiper (stat, (mean, sd), p, cv) (github: aarchiba/kuiper)\n",
          kuiper_ad(np.arange(N)), "\n")
    print("matlab (reject?, p, stat, cv)\n",
          eng.adtest(matlab.double(range(N)), nargout=4), "\n")
    print("R nortest\n",
          importr("nortest").ad_test(FloatVector(range(N))))
    

    output

    statsmodels (stat, pval)
     (0.13400045881773792, 0.96145569293857891) 
    
    scipy
     AndersonResult(statistic=0.13400045881773792, critical_values=array([ 0.519,  0.591,  0.709,  0.827,  0.984]), significance_level=array([ 15. ,  10. ,   5. ,   2.5,   1. ])) 
    
    kuiper (stat, (mean, sd), p, cv) (github: aarchiba/kuiper)
     (0.13400045881773792, (3.5, 2.4494897427831779), (array([ 0.15 ,  0.1  ,  0.05 ,  0.025,  0.01 ]), array([ 0.56 ,  0.632,  0.751,  0.87 ,  1.029])), 1.0) 
    
    matlab (reject?, p, stat, cv)
     (False, 0.9879074013059901, 0.13400045881773792, 0.6667703125000001)
    
    R nortest
    
            Anderson-Darling normality test
    
    data:  c(0, 1, 2, 3, 4, 5, 6, 7)
    A = 0.134, p-value = 0.9615
    

    statsmodels agrees with R; scipy and kuiper, which only give tabulated critical values, use different critical values, and MATLAB's critical value (at p=0.05) is inconsistent with either.

  4. josef-pkt commented on Jul 6, 2015

    @josef-pkt
    Member

    I had looked at scipy, and kuiper before but didn't realize they didn't have the same critical values, at least in a case like this.

    The difference of matlab to statsmodels and R might not mean much, because those p-values are usually targeted for the 0.01 to 0.2 range, and might use only a simplified extrapolation for large p-values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions