jbtest
statistics: h = jbtest (x)
statistics: h = jbtest (x, alpha)
statistics: h = jbtest (x, alpha, mctol)
statistics: [h, p] = jbtest (…)
statistics: [h, p, jbstat, critval] = jbtest (…)
Jarque-Bera hypothesis test of composite normality.
h = jbtest (x) performs the Jarque-Bera test of the null
hypothesis that the sample in the vector x comes from a normal
distribution with unknown mean and variance, against the alternative that it
does not come from a normal distribution. The result h is 1 if the
test rejects the null hypothesis at the 5% significance level, and 0
otherwise. x must be a vector of real values; NaN values are
treated as missing and removed.
The Jarque-Bera test statistic is $$ JB = \frac{n}{6} \left( s^2 + \frac{(k-3)^2}{4} \right), $$ where is the sample size, is the sample skewness, and is the sample kurtosis. Under the null hypothesis it is asymptotically chi-square distributed with two degrees of freedom.
h = jbtest (x, alpha) performs the test at the
significance level alpha, a scalar in the range . The
default is .
h = jbtest (x, alpha, mctol) computes a
Monte-Carlo approximation of the p-value instead of interpolating the
embedded table. mctol is the maximum Monte-Carlo standard
error allowed for the p-value; the number of simulated samples is chosen
accordingly. Use this for small samples, where the chi-square approximation
is inaccurate, or for significance levels outside .
[h, p] = jbtest (…) also returns the p-value
p of the test. p is clamped to the tabulated range
, as MATLAB clamps it, and a warning is issued when the
value lies outside that range. The warning is an addition here: MATLAB
clamps silently, so a p-value reported as or there
may be a bound rather than an estimate, with nothing to say so.
[h, p, jbstat, critval] = jbtest (…) also
returns the test statistic jbstat and the critical value critval
at significance level alpha. The null hypothesis is rejected when
jbstat > critval.
Note: for the p-value and critical value are obtained by interpolating an embedded critical-value table (the same approach MATLAB uses); for larger samples the large-sample chi-square approximation with two degrees of freedom is used instead. The embedded table was generated here by Monte-Carlo simulation, so it is itself an estimate of the true null quantiles. MATLAB’s table is likewise a Monte-Carlo estimate but from a different simulation, so the two tables agree only to about two decimal places. As a result the reported p-value and critical value, and (in a narrow band of statistic values around the critical value) the test decision h, can differ slightly from MATLAB in edge cases. These differences are an unavoidable consequence of the Monte-Carlo origin of both tables, not a difference in method. Supply mctol for a direct Monte-Carlo p-value.
See also: kstest, adtest, lillietest
Source Code: jbtest
Test whether a sample departs from normality
x = [1 2 3 4 5 6 7 8 9 100]; # last value is an outlier [h, p, jbstat] = jbtest (x)
warning: jbtest: P is less than the smallest tabulated value; returning 0.001.
warning: called from
jbtest at line 155 column 9
__eval_demo__ at line 84 column 9
__demo_notebook__ at line 43 column 3
__build_demos__ at line 79 column 7
function_texi2html at line 135 column 5
package_texi2html at line 336 column 9
h = 1
p = 1.0000e-03
jbstat = 21.935