Normality tests

Normality tests#

All parametric procedures in spm1d assume that the model’s residuals are normally distributed. Residuals are available for all results through spm.residuals. Normality tests on those residuals can be conducted via the test_normality method:

spm = spm1d.stats.ttest2( yA, yB )
ni  = spm.test_normality()

test_normality conducts the D’Agostino–Pearson K² test on the residuals of any fitted model. The K² statistic combines both sample skewness and kurtosis and is approximately χ²-distributed with two degrees of freedom under normality. For 1D data, K² is computed at each domain point and forms a K²-field that is thresholded using an RFT correction. The normality test is therefore itself a continuum-level test. Normality is rejected if the K² field exceeds the critical threshold anywhere in the domain.

spm = spm1d.stats.ttest2( yA, yB )
ni  = spm.test_normality()
print( ni )
SPM{X2} (1D) inference
    fn_name : normality_residuals
    STAT    : X2
    z       : (101,) array
    df      : (1, 2)
Smoothness estimates:
    fwhm    : 14.480
    lkc     : 11.500
    resels  : (1, 6.90624)
Inference results:
    method       : rft
    isparametric : True
    alpha        : 0.05
    zc           : 17.80417
    zmax         : 3.121
    h0reject     : False
    p_zmax       : 1.000
    p_set        : None
    p_cluster    : None
    p_point      : None

The output from test_normality is an inference object similar to the outputs from spm1d.stats procedures:

  • STAT is X2 because the K² statistic is approximately χ²-distributed.

  • z is the K²-field with one value per domain point.

The smoothness estimates are the same as those for spm because smoothness estimates are based on spm.residuals and normality tests are conducted directly on spm.residuals without fitting any additional model.

As with any hypothesis test, failure to reject the null hypothesis does not imply normality. Similarly, rejecting the null hypothesis does not necessarily imply non-normality. With small samples the test has little power. With large samples it rejects tiny departures from normality. The test should therefore be regarded as a diagnostic tool rather than a definitive conclusion regarding the underlying distribution.

See also: