当前位置: 代码迷 >> 综合 >> 【Stats】Jarque Bera test正态性检验
  详细解决方案

【Stats】Jarque Bera test正态性检验

热度:85   发布时间:2024-03-09 20:00:53.0

导航

  • Jarque Bera test
  • Scipy.stats.jarque_bera
  • statsmodels.stats.stattools.jarque_bera
    • industry 12 portfolio JB test
  • 参考资料

Jarque Bera test

JB检验主要检验样本数据的skewnesskurtosis是否与正态分布相匹配,统计检验的结果是非负的,如果检验值比0大很多,那么表示样本数据不符合normal distribution.
JB检验的统计量定义为
JB=n6(S2+14(K?3)2)JB=\frac{n}{6}(S^2+\frac{1}{4}(K-3)^2) JB=6n?(S2+41?(K?3)2)
其中,nnn表示样本数量,或者自由度(d.o.f),SSS表示样本skewnessKKK表示样本kurtosis:
{S=μ^3σ^3=1n∑i=1n(xi?xˉ)3(1n∑i=1n(xi?xˉ)2)32K=μ^4σ^4=1n∑i=1n(xi?xˉ)4(1n∑i=1n(xi?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??=(n1?i=1n?(xi??xˉ)2)23?n1?i=1n?(xi??xˉ)3?K=σ^4?μ^?4??=(n1?i=1n?(xi??xˉ))2n1?i=1n?(xi??xˉ)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 statisticp: 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 normalityaxis: int
Returns:JB: float, the Jarque-Bera test statisticJBpv: float, the pvalue of test statisticskew: estimated skewness of the datakurtosis: 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.pvalueprint(f'{ind_name}\t{_jbstats}\t{_pvalue}')

参考资料

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

  相关解决方案