fit#
- pycafee.normalitycheck.abdimolin.AbdiMolin.fit(self, x_exp, alfa=None, details=None)#
This function is a wraper around
statsmodels.stats.diagnostic.lilliefors()[1] to estimate the statistic of the AbdiMolin Normality test. Only the statistic value is used.The main difference between this method and the original one is that this wrap only allows the comparison of a sample with the Normal distribution, using
dist="norm". The method to estimate the p-value is set to table. Hence:>>> statsmodels.stats.diagnostic(x_exp, dist="norm", pvalmethod="table")
- Parameters
- x_exp
numpy array One dimension numpy array with at least
4sample data.- alfa
float, optional The level of significance (
ɑ). Default isNonewhich results in0.05(ɑ = 5%).- details
str, optional The
detailsparameter determines the amount of information presented about the hypothesis test.If
details = "short"(orNone), a simplified version of the test result is returned.If
details = "full", a detailed version of the hypothesis test result is returned.if
details = "binary", the conclusion will be1(\(H_0\) is rejected) or0(\(H_0\) is accepted).
- x_exp
- Returns
- result
tuplewith - statistic
float The test statistic.
- critical
floatorNone The critical value for alpha equal to
1%,5%,10%,15%or20%. Other values will raiseValueError.- p_value
None The p-value for the hypothesis test (always
None).
- statistic
- conclusion
str The test conclusion (e.g, Normal/ not Normal).
- result
See also
Notes
The critical values [2] includes samples with sizes between
4and50forɑequal to1%,5%,10%,15%or20%.For data with a sample size higher than
51(n_rep > 50), the critical value returned is the aproximation proposed by the authors.
The AbdiMolin Normality test [3] has the following premise:
☕
\(H_0:\) data comes from Normal distribution.
\(H_1:\) data does not come from Normal distribution.
The conclusion is based on the comparison between the
criticalvalue (atɑsignificance level) andstatisticof the test. In summary:if critical >= statistic: Data is Normal else: Data is not Normal
If
ɑis not0.01,0.05,0.10,0.15or0.20, the function will raise aValueError.References
- 1
STATSMODELS. statsmodels.stats.diagnostic.lilliefors. Available at: www.statsmodels.org. Access on: 10 May. 2022
- 2
SALKIND, N. J. Encyclopedia of measurement and statistics. California: SAGE Publications, Inc., 2007. DOI: 10.4135/9781412952644.
- 3
MOLIN, P.; ABDI, H. New Tables and numerical approximation for the Kolmogorov- Smirnov/Lillierfors/Van Soest test of normality. p. 1–12, 1998. Available from MolinAbdi1998-LillieforsTechReport.pdf.
Examples
Applying the test with default values
>>> from pycafee.normalitycheck import AbdiMolin >>> import scipy.stats as stats >>> x = stats.norm.rvs(loc=5, scale=3, size=100, random_state=42) >>> abdimolin_test = AbdiMolin() >>> result, conc = abdimolin_test.fit(x) >>> print(result) AbdiMolinResult(Statistic=0.05177647360597687, Critical=0.0888513848903008, p_value=None, Alpha=0.05) >>> print(conc) Data is Normal at a 95.0% of confidence level.
Applying the test with
alfa=0.10>>> from pycafee.normalitycheck import AbdiMolin >>> import numpy as np >>> x = np.array([1.90642, 2.22488, 2.10288, 1.69742, 1.52229, 3.15435, 2.61826, 1.98492, 1.42738, 1.99568]) >>> abdimolin_test = AbdiMolin() >>> result, conc = abdimolin_test.fit(x, alfa=0.01) >>> print(result) AbdiMolinResult(Statistic=0.17709753067016487, Critical=0.3037, p_value=None, Alpha=0.01) >>> print(conc) Data is Normal at a 99.0% of confidence level.
Applying the test with
alfa=0.10anddetails="full">>> from pycafee.normalitycheck import AbdiMolin >>> import numpy as np >>> x = np.array([5.1, 4.9, 4.7, 4.6, 5.0, 5.4, 4.6, 5.0, 4.4, 4.9]) >>> abdimolin_test = AbdiMolin() >>> result, conc = abdimolin_test.fit(x, alfa=0.10, details="full") >>> print(result) AbdiMolinResult(Statistic=0.15459867079959644, Critical=0.241, p_value=None, Alpha=0.1) >>> print(conc) Since the critical value (0.241) >= statistic (0.154), we have NO evidence to reject the hypothesis of data normality, according to the AbdiMolin test at a 90.0% of confidence level.
Applying the test with
details="full">>> from pycafee.normalitycheck import AbdiMolin >>> import numpy as np >>> x = np.array([0.8, 1, 1.1, 1.15, 1.15, 1.2, 1.2, 1.2, 1.2, 1.6, 1.8, 2, 2.2, 3, 5, 8.2, 8.4, 8.6, 9]) >>> abdimolin_test = AbdiMolin() >>> result, conc = abdimolin_test.fit(x, details="full") >>> print(result) AbdiMolinResult(Statistic=0.3072356484569813, Critical=0.1965, p_value=None, Alpha=0.05) >>> print(conc) Since the critical value (0.196) < statistic (0.307), we HAVE evidence to reject the hypothesis of data normality, according to the AbdiMolin test at a 95.0% of confidence level.