statsmodels.stats.diagnostic.compare_j#

statsmodels.stats.diagnostic.compare_j(results_x, results_z, store=False, *, use_namedtuple=None)[source]#

Compute the J-test for non-nested models

Parameters:
results_xRegressionResults

The result instance of first model.

results_zRegressionResults

The result instance of second model.

storebool, default False

If true, then the intermediate results are returned.

use_namedtuplebool, optional

Flag indicating whether to return the results as a NonNestedTestResult NamedTuple instead of a plain tuple. When store=True the NamedTuple holds the same three elements as the legacy tuple, so it unpacks identically and is always returned, with no warning. When store=False the legacy two-element tuple is returned by default and a FutureWarning is issued.

Deprecated since version 0.15.0: In release 0.16.0 or after July 2027, whichever is later, the default will change to always return a NonNestedTestResult. Set use_namedtuple=True to opt in now, or use_namedtuple=False to silence the warning and keep the current return type.

Returns:
NonNestedTestResult

If use_namedtuple=True, a NamedTuple with fields tstat, pvalue, and res_store (res_store is None when not computed). See NonNestedTestResult.

Otherwise (the deprecated default), a plain tuple made up of:
tstatfloat

t statistic for the test that including the fitted values of the first model in the second model has no effect.

pvaluefloat

two-sided pvalue for the t statistic

res_storeResultsStore, optional

Intermediate results. Returned if store is True.

Notes

From description in Greene, section 8.3.3. Matches results for Example 8.3, Greene.

Tests of non-nested hypothesis might not provide unambiguous answers. The test should be performed in both directions and it is possible that both or neither test rejects. See Greene for more information.

References

[1]

Greene, W. H. Econometric Analysis. New Jersey. Prentice Hall; 5th edition. (2002).