LinearModelTest_LinearModelDurbinWatson

LinearModelTest_LinearModelDurbinWatson(*args)

Test the autocorrelation of the linear regression model residuals.

Available usages:

LinearModelTest.LinearModelDurbinWatson(firstSample, secondSample)

LinearModelTest.LinearModelDurbinWatson(firstSample, secondSample, hypothesis, level)

LinearModelTest.LinearModelDurbinWatson(firstSample, secondSample, linearModel)

LinearModelTest.LinearModelDurbinWatson(firstSample, secondSample, linearModel, hypothesis, level)

Parameters:

fisrtSample : 2-d sequence of float

First tested sample, of dimension 1.

secondSample : 2-d sequence of float

Second tested sample, of dimension 1.

linearModel : LinearModel

A linear model. If not provided, it is built using the given samples.

hypothesis : string

Hypothesis H0 for the residuals. It can be : ‘Equal’ to 0, ‘Less’ than 0 or ‘Greater’ than 0. Default is set to ‘Equal’ to 0.

level : positive float < 1

Threshold p-value of the test (= 1 - first type risk), it must be < 1, equal to 0.95 by default.

Returns:

testResult : TestResult

Structure containing the result of the test.

Notes

The LinearModelTest class is used through its static methods in order to evaluate the quality of the linear regression model between two samples (see LinearModel). The linear regression model between the scalar variable Y and the n-dimensional one \vect{X} = (X_i)_{i \leq n} is as follows:

\tilde{Y} = a_0 + \sum_{i=1}^n a_i X_i + \epsilon

where \epsilon is the residual.

The Durbin-Watson test checks the autocorrelation of the residuals. It is possible to test is the autocorrelation is equal to 0, and less or greater than 0. The p-value is computed using a normal approximation with mean and variance of the Durbin-Watson test statistic. If the binary quality measure is false, then the given autocorrelation hypothesis can be rejected with respect to the given level.

Examples

>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> distribution = ot.Normal()
>>> sample = distribution.getSample(30)
>>> func = ot.SymbolicFunction('x', '2 * x + 1')
>>> firstSample = sample
>>> secondSample = func(sample) + ot.Normal().getSample(30)
>>> test_result = ot.LinearModelTest.LinearModelDurbinWatson(firstSample, secondSample)
>>> print(test_result)
class=TestResult name=Unnamed type=DurbinWatson binaryQualityMeasure=true p-value threshold=0.95 p-value=0.653603 description=[Hypothesis test: autocorrelation equals 0.]