Main Content

jbtest

Jarque-Bera test

Description

h = jbtest(x) returns a test decision for the null hypothesis that the data in vector x comes from a normal distribution with an unknown mean and variance, using the Jarque-Bera test. The alternative hypothesis is that it does not come from such a distribution. The result h is 1 if the test rejects the null hypothesis at the 5% significance level, and 0 otherwise.

example

h = jbtest(x,alpha) returns a test decision for the null hypothesis at the significance level specified by alpha.

example

h = jbtest(x,alpha,mctol) returns a test decision based on a p-value computed using a Monte Carlo simulation with a maximum Monte Carlo standard error less than or equal to mctol.

example

[h,p] = jbtest(___) also returns the p-value p of the hypothesis test, using any of the input arguments from the previous syntaxes.

example

[h,p,jbstat,critval] = jbtest(___) also returns the test statistic jbstat and the critical value critval for the test.

example

Examples

collapse all

Load the data set.

load carbig

Test the null hypothesis that car mileage, in miles per gallon (MPG), follows a normal distribution across different makes of cars.

h = jbtest(MPG)
h = 
1

The returned value of h = 1 indicates that jbtest rejects the null hypothesis at the default 5% significance level.

Load the data set.

load carbig

Test the null hypothesis that car mileage in miles per gallon (MPG) follows a normal distribution across different makes of cars at the 1% significance level.

[h,p] = jbtest(MPG,0.01)
h = 
1
p = 
0.0022

The returned value of h = 1, and the returned p-value less than α = 0.01 indicate that jbtest rejects the null hypothesis.

Load the data set.

load carbig

Test the null hypothesis that car mileage, in miles per gallon (MPG), follows a normal distribution across different makes of cars. Use a Monte Carlo simulation to obtain an exact p-value.

[h,p,jbstat,critval] = jbtest(MPG,[],0.0001)
h = 
1
p = 
0.0022
jbstat = 
18.2275
critval = 
5.8461

The returned value of h = 1 indicates that jbtest rejects the null hypothesis at the default 5% significance level. Additionally, the test statistic, jbstat, is larger than the critical value, critval, which indicates rejection of the null hypothesis.

Input Arguments

collapse all

Sample data for the hypothesis test, specified as a vector. jbtest treats NaN values in x as missing values and ignores them.

Data Types: single | double

Significance level of the hypothesis test, specified as a scalar value in the range (0,1). If alpha is in the range [0.001,0.50], and if the sample size is less than or equal to 2000, jbtest looks up the critical value for the test in a table of precomputed values. To conduct the test at a significance level outside of these specifications, use mctol.

Example: 0.01

Data Types: single | double

Maximum Monte Carlo standard error for the p-value, p, specified as a nonnegative scalar value. If you specify a value for mctol, jbtest computes a Monte Carlo approximation for p directly, rather than interpolating into a table of precomputed values. jbtest chooses the number of Monte Carlo replications large enough to make the Monte Carlo standard error for p less than mctol.

If you specify a value for mctol, you must also specify a value for alpha. You can specify alpha as [] to use the default value of 0.05.

Example: 0.0001

Data Types: single | double

Output Arguments

collapse all

Hypothesis test result, returned as 1 or 0.

  • If h = 1, this indicates the rejection of the null hypothesis at the alpha significance level.

  • If h = 0, this indicates a failure to reject the null hypothesis at the alpha significance level.

p-value of the test, returned as a scalar value in the range (0,1). p is the probability of observing a test statistic as extreme as, or more extreme than, the observed value under the null hypothesis. Small values of p cast doubt on the validity of the null hypothesis.

jbtest warns when p is not found within the tabulated range of [0.001,0.50], and returns either the smallest or largest tabulated value. In this case, you can use mctol to compute a more accurate p-value.

Test statistic for the Jarque-Bera test, returned as a nonnegative scalar value.

Critical value for the Jarque-Bera test at the alpha significance level, returned as a nonnegative scalar value. If alpha is in the range [0.001,0.50], and if the sample size is less than or equal to 2000, jbtest looks up the critical value for the test in a table of precomputed values. If you use mctol, jbtest determines the critical value of the test using a Monte Carlo simulation. The null hypothesis is rejected when jbstat > critval.

More About

collapse all

Jarque-Bera Test

The Jarque-Bera test is a two-sided goodness-of-fit test suitable when a fully specified null distribution is unknown and its parameters must be estimated.

The test is specifically designed for alternatives in the Pearson system of distributions. The test statistic is

JB=n6(s2+(k3)24),

where n is the sample size, s is the sample skewness, and k is the sample kurtosis. For large sample sizes, the test statistic has a chi-square distribution with two degrees of freedom.

Monte Carlo Standard Error

The Monte Carlo standard error is the error due to simulating the p-value.

The Monte Carlo standard error is calculated as

SE=(p^)(1p^)mcreps,

where p^ is the estimated p-value of the hypothesis test, and mcreps is the number of Monte Carlo replications performed. jbtest chooses the number of Monte Carlo replications, mcreps, large enough to make the Monte Carlo standard error for p^ less than the value specified for mctol.

Algorithms

Jarque-Bera tests often use the chi-square distribution to estimate critical values for large samples, deferring to the Lilliefors test (see lillietest) for small samples. jbtest, by contrast, uses a table of critical values computed using Monte Carlo simulation for sample sizes less than 2000 and significance levels from 0.001 to 0.50. Critical values for a test are computed by interpolating into the table, using the analytic chi-square approximation only when extrapolating for larger sample sizes.

References

[1] Jarque, C. M., and A. K. Bera. “A Test for Normality of Observations and Regression Residuals.” International Statistical Review. Vol. 55, No. 2, 1987, pp. 163–172.

[2] Deb, P., and M. Sefton. “The Distribution of a Lagrange Multiplier Test of Normality.” Economics Letters. Vol. 51, 1996, pp. 123–130. This paper proposed a Monte Carlo simulation for determining the distribution of the test statistic. The results of this function are based on an independent Monte Carlo simulation, not the results in this paper.

Version History

Introduced before R2006a