【Stats】Jarque Bera test正态性检验

Jarque Bera test

JB检验主要检验样本数据的skewnesskurtosis是否与正态分布相匹配,统计检验的结果是非负的,如果检验值比0大很多,那么表示样本数据不符合normal distribution.
JB检验的统计量定义为
J B = n 6 ( S 2 + 1 4 ( K − 3 ) 2 ) JB=\frac{n}{6}(S^2+\frac{1}{4}(K-3)^2) JB=6n(S2+41(K3)2)
其中, n n n表示样本数量,或者自由度(d.o.f), S S S表示样本skewness K K K表示样本kurtosis:
{ S = μ ^ 3 σ ^ 3 = 1 n ∑ i = 1 n ( x i − x ˉ ) 3 ( 1 n ∑ i = 1 n ( x i − x ˉ ) 2 ) 3 2 K = μ ^ 4 σ ^ 4 = 1 n ∑ i = 1 n ( x i − x ˉ ) 4 ( 1 n ∑ i = 1 n ( x i − x ˉ ) ) 2 \begin{cases} S=\frac{\hat{\mu}_3}{\hat{\sigma}^3}=\frac{\frac{1}{n}\sum_{i=1}^n(x_i-\bar{x})^3}{(\frac{1}{n}\sum_{i=1}^n(x_i-\bar{x})^2)^{\frac{3}{2}}}\\ K=\frac{\hat{\mu}_4}{\hat{\sigma}_4}=\frac{\frac{1}{n}\sum_{i=1}^n(x_i-\bar{x})^4}{(\frac{1}{n}\sum_{i=1}^n(x_i-\bar{x}))^2} \end{cases} S=σ^3μ^3=(n1i=1n(xixˉ)2)23n1i=1n(xixˉ)3K=σ^4μ^4=(n1i=1n(xixˉ))2n1i=1n(xixˉ)4
如果数据采样自一个正态分布的总体,那么JB检验渐近于 χ ( 2 ) \chi(2) χ(2)分布,假设检验的零假设为一个联合假设(joint hypothesis):偏度为0且超额峰度为0.

If the data comes from a normal distribution, the JB statistic asymptotically has a chi-squared distribution with two degrees of freedom,so the statistic can be used to test the hypothesis that the data are from a normal distribution. The null hypothesis is a joint hypothesis of the skewness being zero and the excess kurtosis being zero. Samples from a normal distribution have an expected skewness of 0 and an expected excess kurtosis of 0. As the definition of JB shows, any deviation from this increases the JB statistic.

Scipy.stats.jarque_bera

scipy.stats.jarque_bera(x)

Parameter: 
	x: array_like  // obsverations of a random variable
Returns:
	jb_value: float, the test statistic
	p: the p-value for the hypothesis test

statsmodels.stats.stattools.jarque_bera

statsmodels.stats.stattools.jarque_bera(resids, axis=0)

Parameters:
	resids: array_like // data to test for normality
	axis: int
Returns:
	JB: float, the Jarque-Bera test statistic
	JBpv: float, the pvalue of test statistic
	skew: estimated skewness of the data
	kurtosis: estimated kurtosis of the data

industry 12 portfolio JB test

对美国12个行业指数returns进行JB检验

def JB_test(df, ind_names):
    if df is None or ind_names is None: raise Exception('Data Frame is None')
    for ind_name in ind_names:
        ind_returns = df[ind_name]
        jb_ans = JB(ind_returns)
        # print(jb_ans)
        _jbstats, _pvalue = jb_ans.statistic, jb_ans.pvalue
        print(f'{ind_name}\t{_jbstats}\t{_pvalue}')

参考资料

python数据正态性检验
Jarque Bera test. wiki
JB正态性检验
scipy jarque_bera

SPSS正态性检验是一种用于检验数据样本是否来自正态分布的统计方法。在实际应用中,正态性检验常用于检验数据是否符合线性回归等统计模型的假设要求。 在SPSS中,进行正态性检验的方法有多种,常用的包括Shapiro-Wilk检验和Kolmogorov-Smirnov检验。 Shapiro-Wilk检验是常用的正态性检验方法之一,该方法根据样本数据的观测值与均值之间的关系来判断数据是否来自正态分布。在SPSS中,可以通过在“分析”菜单下点击“描述统计-探索性数据分析”来进行Shapiro-Wilk检验。在弹出的对话框中,选择要进行检验的变量,并勾选上“正态性检验”选项,然后点击“确定”即可得到检验结果。 Kolmogorov-Smirnov检验也是一种常用的正态性检验方法,该方法通过计算样本数据与理论正态分布累积分布函数之间的差异来判断数据是否来自正态分布。在SPSS中,可以通过在“分析”菜单下点击“非参数检验-单样本-检验正态分布”来进行Kolmogorov-Smirnov检验。在弹出的对话框中,选择要进行检验的变量,并填写理论正态分布的均值和标准差,然后点击“确定”即可得到检验结果。 无论是哪种方法,通常会输出检验的统计量和显著性水平。如果显著性水平小于预设的显著性水平(通常为0.05),则可以拒绝原假设,即认为数据样本不来自正态分布。 需要注意的是,正态性检验是基于样本数据进行的,因此检验结果并不能完全确定数据总体是否来自正态分布,只能提供一定程度的参考。此外,对于小样本数据,正态性检验的可靠性也会受到限制,因此在实际应用中需要综合考虑其他因素来判断数据是否符合正态分布的要求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Quant0xff

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值