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, linearModelResult)
LinearModelTest.LinearModelDurbinWatson(firstSample, secondSample, linearModelResult, hypothesis, level)
 Parameters
 firstSample2d sequence of float
First tested sample.
 secondSample2d sequence of float
Second tested sample, of dimension 1.
 linearModelResult
LinearModelResult
A linear model. If not provided, it is built using the given samples.
 hypothesisstr
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.
 levelpositive float
Threshold pvalue of the test (= first kind risk), it must be , equal to 0.05 by default.
 Returns
 testResult
TestResult
Structure containing the result of the test.
 testResult
See also
Notes
The LinearModelTest class is used through its static methods in order to evaluate the quality of the linear regression model between two samples. The linear regression model between the scalar variable and the dimensional one is as follows:
where is the residual.
The DurbinWatson 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 pvalue is computed using a normal approximation with mean and variance of the DurbinWatson 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 pvalue threshold=0.05 pvalue=0.653603 statistic=0.448763 description=[H0: auto.cor=0]