statsmodels.regression.linear_model.OLSResults.compare_lm_test

OLSResults.compare_lm_test(restricted, demean=True, use_lr=False)

Use Lagrange Multiplier test to test a set of linear restrictions.

Parameters:
restrictedResult instance

The restricted model is assumed to be nested in the current model. The result instance of the restricted model is required to have two attributes, residual sum of squares, ssr, residual degrees of freedom, df_resid.

demeanbool

Flag indicating whether the demean the scores based on the residuals from the restricted model. If True, the covariance of the scores are used and the LM test is identical to the large sample version of the LR test.

use_lrbool

A flag indicating whether to estimate the covariance of the model scores using the unrestricted model. Setting the to True improves the power of the test.

Returns:
lm_valuefloat

The test statistic which has a chi2 distributed.

p_valuefloat

The p-value of the test statistic.

df_diffint

The degrees of freedom of the restriction, i.e. difference in df between models.

Notes

The LM test examines whether the scores from the restricted model are 0. If the null is true, and the restrictions are valid, then the parameters of the restricted model should be close to the minimum of the sum of squared errors, and so the scores should be close to zero, on average.


Last update: Oct 03, 2024