spreg.jarque_bera

spreg.jarque_bera(reg)[source]

Jarque-Bera test for normality in the residuals. [JB80]

Parameters:
regregression object

output instance from a regression model

Returns:
jb_resultdictionary

contains the statistic (jb) for the Jarque-Bera test and the associated p-value (p-value)

dfinteger

degrees of freedom for the test (always 2)

jbfloat

value of the test statistic

pvaluefloat

p-value associated with the statistic (chi^2 distributed with 2 df)

Examples

>>> import numpy as np
>>> import libpysal
>>> from libpysal import examples
>>> import spreg
>>> from spreg import OLS

Read the DBF associated with the Columbus data.

>>> db = libpysal.io.open(examples.get_path("columbus.dbf"), "r")

Create the dependent variable vector.

>>> y = np.array(db.by_col("CRIME"))
>>> y = np.reshape(y, (49,1))

Create the matrix of independent variables.

>>> X = []
>>> X.append(db.by_col("INC"))
>>> X.append(db.by_col("HOVAL"))
>>> X = np.array(X).T

Run an OLS regression.

>>> reg = OLS(y,X)

Calculate the Jarque-Bera test for normality of residuals.

>>> testresult = spreg.jarque_bera(reg)

Print the degrees of freedom for the test.

>>> testresult['df']
2

Print the test statistic.

>>> print("%1.3f"%testresult['jb'])
1.836

Print the associated p-value.

>>> print("%1.4f"%testresult['pvalue'])
0.3994