FullRegression¶
- FullRegression(firstSample, secondSample, level=0.05)¶
Test a linear correlation between two samples.
Available usages:
LinearModelTest.FullRegression(firstSample, secondSample)
LinearModelTest.FullRegression(firstSample, secondSample, level)
- Parameters:
- firstSample2-d sequence of float
First tested sample, of dimension
.
- secondSample2-d sequence of float
Second tested sample, of dimension 1.
- levelpositive float
Threshold p-value of the test (error Type I).
Default value is 0.05.
- Returns:
- testResultsCollection of
TestResult Results for each component of the linear model including intercept.
- testResultsCollection of
Notes
The FullRegression method fits a linear model between
with respect to
from a sample of
(called firstSample) and a sample of
(called secondSample):
The method returns a collection of
TestResultthat tests the null hypothesis: The coefficient is null for each coefficient of the linear relation:. The statistics used is detailed in
LinearModelAnalysisand is based on the evaluation of the: see
getCoefficientsTScores()andgetCoefficientsPValues().If the result of the test is True, then the coefficient is assumed to be null: there is no linear relation between the tested components. If the result of the test is False, then the coefficient is assumed to be significantly different from 0: there is a linear relation between the tested components.
Examples
We create a sample generated by a Gaussian vector
with zero mean, unit variance and which components
are correlated.
We fit the linear model:
and we test if each coefficient is significantly different from 0. >>> import openturns as ot >>> ot.RandomGenerator.SetSeed(0) >>> S = ot.CorrelationMatrix(3) >>> distribution = ot.Normal([0]*3, [1]*3, S) >>> sample = distribution.getSample(100) >>> firstSample = sample.getMarginal([0,1]) >>> secondSample = sample.getMarginal(2) >>> test_result = ot.LinearModelTest.FullRegression(firstSample, secondSample) >>> for i in range(3): … print(‘Test for a’ + str(i) + ‘ :’ , test_result[i]) Test for a0 : class=TestResult name=Unnamed type=Regression binaryQualityMeasure=true p-value threshold=0.05 p-value=0.82575 statistic=-0.220751 description=[] Test for a1 : class=TestResult name=Unnamed type=Regression binaryQualityMeasure=true p-value threshold=0.05 p-value=0.242986 statistic=1.17471 description=[] Test for a2 : class=TestResult name=Unnamed type=Regression binaryQualityMeasure=true p-value threshold=0.05 p-value=0.363986 statistic=0.912083 description=[]
OpenTURNS