statsmodels.stats.diagnostic.linear_rainbow

statsmodels.stats.diagnostic.linear_rainbow(res, frac=0.5, order_by=None, use_distance=False, center=None)[source]

Rainbow test for linearity

The null hypothesis is the fit of the model using full sample is the same as using a central subset. The alternative is that the fits are difference. The rainbow test has power against many different forms of nonlinearity.

Parameters:
resRegressionResults

A results instance from a linear regression.

fracfloat, default 0.5

The fraction of the data to include in the center model.

order_by{ndarray, str, List[str]}, default None

If an ndarray, the values in the array are used to sort the observations. If a string or a list of strings, these are interpreted as column name(s) which are then used to lexicographically sort the data.

use_distancebool, default False

Flag indicating whether data should be ordered by the Mahalanobis distance to the center.

center{float, int}, default None

If a float, the value must be in [0, 1] and the center is center * nobs of the ordered data. If an integer, must be in [0, nobs) and is interpreted as the observation of the ordered data to use.

Returns:
fstatfloat

The test statistic based on the F test.

pvaluefloat

The pvalue of the test.

Notes

This test assumes residuals are homoskedastic and may reject a correct linear specification if the residuals are heteroskedastic.


Last update: Oct 29, 2023