LinearModelTest_PartialRegression

LinearModelTest_PartialRegression(firstSample, secondSample, selection, level=0.05)

Test whether two discrete samples are independent.

Available usages:

LinearModelTest.PartialRegression(firstSample, secondSample, selection)

LinearModelTest.PartialRegression(firstSample, secondSample, selection, level)

Parameters
firstSample2-d sequence of float

First tested sample, of dimension n \geq 1.

secondSample2-d sequence of float

Second tested sample, of dimension 1.

selectionsequence of int, maximum integer value < n

List of indices selecting which subsets of the first sample will successively be tested with the second sample through the regression test.

levelpositive float < 1

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

Returns
testResultsCollection of TestResult

Results for each component of the linear model including intercept.

Notes

The Partial Regression Test is used to assess the linearity between a subset of components of firstSample and secondSample. The parameter selection enables to select specific subsets of the firstSample to be tested.

Examples

>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> dim = 3
>>> distCol = [ot.Normal()] * dim
>>> S = ot.CorrelationMatrix(dim)
>>> S[0, dim - 1] = 0.99
>>> copula = ot.NormalCopula(S)
>>> distribution = ot.ComposedDistribution(distCol, copula)
>>> sample = distribution.getSample(30)
>>> firstSample = sample[:, :2]
>>> secondSample = sample[:, 2]
>>> selection = [1]
>>> test_result = ot.LinearModelTest.PartialRegression(firstSample, secondSample, selection)
>>> print(test_result[1])
class=TestResult name=Unnamed type=Regression binaryQualityMeasure=true p-value threshold=0.05 p-value=0.579638 statistic=-0.560438 description=[]