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 p \geq 1.

secondSample2-d sequence of float

Second tested sample, of dimension 1.

levelpositive float < 1

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.

Notes

The FullRegression method fits a linear model between Y with respect to (X_1, \dots, X_p) from a sample of (X_1, \dots, X_p) (called firstSample) and a sample of Y (called secondSample):

Y = a_0 + \sum_{k=1}^{p}X_k

The method returns a collection of TestResult that tests the null hypothesis: The coefficient is null for each coefficient of the linear relation: (a_0, \dots, a_p). The statistics used is detailed in LinearModelAnalysis and is based on the evaluation of the t_{score}: see getCoefficientsTScores() and getCoefficientsPValues().

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 (X_1, X_2, X_3) with zero mean, unit variance and which components (X_1, X_3) are correlated.

We fit the linear model: X_3 = a_0 + a_1X_1 + a_2X_2 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=[]

Examples using the function

Test independence

Test independence