LinearModelBreuschPagan¶
- LinearModelBreuschPagan(*args)¶
Test the homoskedasticity of the linear regression model residuals.
Available usages:
LinearModelTest.LinearModelBreuschPagan(firstSample, secondSample)
LinearModelTest.LinearModelBreuschPagan(firstSample, secondSample, linearModelResult)
LinearModelTest.LinearModelBreuschPagan(firstSample, secondSample, level)
LinearModelTest.LinearModelBreuschPagan(firstSample, secondSample, linearModelResult, level)
- Parameters
- firstSample2-d sequence of float
First tested sample, of dimension 1.
- secondSample2-d sequence of float
Second tested sample, of dimension 1.
- linearModelResult
LinearModelResult
A linear model. If not provided, it is built using the given samples.
- levelpositive float
Threshold p-value 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
LinearModelTest.LinearModelHarrisonMcCabe
,LinearModelTest.LinearModelResidualMean
LinearModelTest.LinearModelDurbinWatson
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 Breusch-Pagan test checks the heteroskedasticity of the residuals. A linear regression model is fitted on the squared residuals. The statistic is computed using the Studendized version with the chi-squared distribution. If the binary quality measure is false, then the homoskedasticity 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.LinearModelBreuschPagan(firstSample, secondSample) >>> print(test_result) class=TestResult name=Unnamed type=BreuschPagan binaryQualityMeasure=true p-value threshold=0.05 p-value=0.700772 statistic=0.14767 description=[]