tests.shapiro_francia

tests.shapiro_francia(array)

The statistical test of Shapiro-Francia considers the squared correlation between the ordered sample values and the (approximated) expected ordered quantiles from the standard normal distribution.

The p-value is computed from the formula given by Royston (1993). This function performs the Shapiro-Francia test for the composite hypothesis of normality, according to Thode Jr. (2002).

Example

In [1]: import pandas as pd

In [2]: import statsmodels.api as sm

In [3]: from statstests.datasets import bebes

In [4]: from statstests.tests import shapiro_francia

# import bebes dataset
In [5]: df = bebes.get_data()

# Estimate and fit model
In [6]: model = sm.OLS.from_formula('comprimento ~ idade', df).fit()

# Print summary
In [7]: print(model.summary())
                            OLS Regression Results                            
==============================================================================
Dep. Variable:            comprimento   R-squared:                       0.903
Model:                            OLS   Adj. R-squared:                  0.901
Method:                 Least Squares   F-statistic:                     667.7
Date:                Thu, 20 Oct 2022   Prob (F-statistic):           3.72e-38
Time:                        14:03:22   Log-Likelihood:                -207.26
No. Observations:                  74   AIC:                             418.5
Df Residuals:                      72   BIC:                             423.1
Df Model:                           1                                         
Covariance Type:            nonrobust                                         
==============================================================================
                 coef    std err          t      P>|t|      [0.025      0.975]
------------------------------------------------------------------------------
Intercept     43.1004      1.034     41.665      0.000      41.038      45.163
idade          0.9411      0.036     25.841      0.000       0.868       1.014
==============================================================================
Omnibus:                       21.203   Durbin-Watson:                   0.278
Prob(Omnibus):                  0.000   Jarque-Bera (JB):               29.159
Skew:                          -1.218   Prob(JB):                     4.66e-07
Kurtosis:                       4.877   Cond. No.                         62.7
==============================================================================

Notes:
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.

# Print statistics of the normality test
In [8]: shapiro_francia(model.resid)
method  :  Shapiro-Francia normality test
statistics W  :  0.9087044262594457
statistics z  :  3.627650491545381
p-value  :  0.00014300603555437565
Out[8]: 
{'method': 'Shapiro-Francia normality test',
 'statistics W': 0.9087044262594457,
 'statistics z': 3.627650491545381,
 'p-value': 0.00014300603555437565}

The statistical test of Shapiro-Francia considers the squared correlation between the ordered sample values and the (approximated) expected ordered quantiles from the standard normal distribution.

The p-value is computed from the formula given by Royston (1993). This function performs the Shapiro-Francia test for the composite hypothesis of normality, according to Thode Jr. (2002).

References

[1]

Royston, P. (1993). A pocket-calculator algorithm for the Shapiro-Francia test for non-normality: an application to medicine. Statistics in Medicine, 12, 181-184.

[2]

Thode Jr., H. C. (2002). Testing for Normality. Marcel Dekker, New York.