导航
- Jarque Bera test
- Scipy.stats.jarque_bera
- statsmodels.stats.stattools.jarque_bera
-
- industry 12 portfolio JB test
- 参考资料
Jarque Bera test
JB
检验主要检验样本数据的skewness
和kurtosis
是否与正态分布相匹配,统计检验的结果是非负的,如果检验值比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表示样本skewness
,KKK表示样本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
withtwo degrees of freedom
,so the statistic can be used to test the hypothesis that the data are from anormal distribution
. Thenull 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 of0
and an expected excess kurtosis of0
. As the definition of JB shows, any deviation from this increases theJB 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