LinearModelAnalysis¶

class
LinearModelAnalysis
(*args)¶ Analyse a linear model.
 Available constructors:
LinearModelAnalysis(linearModelResult)
 Parameters
 linearModelResult
LinearModelResult
A linear model result.
 linearModelResult
See also
Notes
This class relies on a linear model result structure and performs diagnostic of linearity. This diagnostic mainly relies on graphics and a summary like function (prettyprint)
By default, on graphs, labels of the 3 most significant points are displayed. This number can be changed by modifying the ResourceMap key (
LinearModelAnalysisIdentifiers
).Examples
>>> import openturns as ot >>> ot.RandomGenerator.SetSeed(0) >>> distribution = ot.Normal() >>> Xsample = distribution.getSample(30) >>> func = ot.SymbolicFunction(['x'], ['2 * x + 1']) >>> Ysample = func(Xsample) + ot.Normal().getSample(30) >>> algo = ot.LinearModelAlgorithm(Ysample, Xsample) >>> result = algo.getResult() >>> analysis = ot.LinearModelAnalysis(result)
Methods
drawCookDistance
(self)Accessor to plot of Cook’s distances versus row labels.
drawCookVsLeverages
(self)Accessor to plot of Cook’s distances versus leverage/(1leverage).
drawModelVsFitted
(self)Accessor to plot of model versus fitted values.
drawQQplot
(self)Accessor to plot a Normal quantilesquantiles plot of standardized residuals.
drawResidualsVsFitted
(self)Accessor to plot of residuals versus fitted values.
drawResidualsVsLeverages
(self)Accessor to plot of residuals versus leverages that adds bands corresponding to Cook’s distances of 0.5 and 1.
drawScaleLocation
(self)Accessor to a ScaleLocation plot of sqrt(abs(residuals)) versus fitted values.
getClassName
(self)Accessor to the object’s name.
getCoefficientsConfidenceInterval
(self[, level])Accessor to the confidence interval of level for the coefficients of the linear expansion
getCoefficientsPValues
(self)Accessor to the coefficients of the p values.
getCoefficientsTScores
(self)Accessor to the coefficients of linear expansion over their standard error.
getFisherPValue
(self)Accessor to the Fisher p value.
getFisherScore
(self)Accessor to the Fisher test.
getId
(self)Accessor to the object’s id.
getLinearModelResult
(self)Accessor to the linear model result.
getName
(self)Accessor to the object’s name.
Performs CramerVon Mises test.
Performs AndersonDarling test.
Performs ChiSquare test.
Performs Kolmogorov test.
getShadowedId
(self)Accessor to the object’s shadowed id.
getVisibility
(self)Accessor to the object’s visibility state.
hasName
(self)Test if the object is named.
hasVisibleName
(self)Test if the object has a distinguishable name.
setName
(self, name)Accessor to the object’s name.
setShadowedId
(self, id)Accessor to the object’s shadowed id.
setVisibility
(self, visible)Accessor to the object’s visibility state.

__init__
(self, *args)¶ Initialize self. See help(type(self)) for accurate signature.

drawCookVsLeverages
(self)¶ Accessor to plot of Cook’s distances versus leverage/(1leverage).
 Returns
 graph
Graph
 graph

drawQQplot
(self)¶ Accessor to plot a Normal quantilesquantiles plot of standardized residuals.
 Returns
 graph
Graph
 graph

drawResidualsVsLeverages
(self)¶ Accessor to plot of residuals versus leverages that adds bands corresponding to Cook’s distances of 0.5 and 1.
 Returns
 graph
Graph
 graph

drawScaleLocation
(self)¶ Accessor to a ScaleLocation plot of sqrt(abs(residuals)) versus fitted values.
 Returns
 graph
Graph
 graph

getClassName
(self)¶ Accessor to the object’s name.
 Returns
 class_namestr
The object class name (object.__class__.__name__).

getCoefficientsConfidenceInterval
(self, level=0.95)¶ Accessor to the confidence interval of level for the coefficients of the linear expansion
 Returns
 confidenceInterval
Interval
 confidenceInterval

getCoefficientsTScores
(self)¶ Accessor to the coefficients of linear expansion over their standard error.
 Returns
 tScores
Point
 tScores

getFisherPValue
(self)¶ Accessor to the Fisher p value.
 Returns
 fisherPValuefloat

getFisherScore
(self)¶ Accessor to the Fisher test.
 Returns
 fisherScorefloat

getId
(self)¶ Accessor to the object’s id.
 Returns
 idint
Internal unique identifier.

getLinearModelResult
(self)¶ Accessor to the linear model result.
 Returns
 linearModelResult
LinearModelResult
The linear model result which had been passed to the constructor.
 linearModelResult

getName
(self)¶ Accessor to the object’s name.
 Returns
 namestr
The name of the object.

getNormalityTestCramerVonMises
(self)¶ Performs CramerVon Mises test.
The statistical test checks the Gaussian assumption of the model (null hypothesis).
 Returns
 testResult
TestResult
Test result class.
 testResult
Notes
We check that the residual is Gaussian thanks to
NormalityTest::CramerVonMisesNormal
.

getNormalityTestResultAndersonDarling
(self)¶ Performs AndersonDarling test. The statistical test checks the Gaussian assumption of the model (null hypothesis).
 Returns
 testResult
TestResult
Test result class.
 testResult
Notes
We check that the residual is Gaussian thanks to
NormalityTest::AndersonDarling
.

getNormalityTestResultChiSquared
(self)¶ Performs ChiSquare test. The statistical test checks the Gaussian assumption of the model (null hypothesis).
 Returns
 testResult
TestResult
Test result class.
 testResult
Notes
The ChiSquare test is a goodness of fit test which objective is to check the normality assumption (null hypothesis) of residuals (and thus the model).
Usually, ChiSquare test applies for discrete distributions. Here we rely on the
FittingTest_ChiSquared
to check the normality.

getNormalityTestResultKolmogorovSmirnov
(self)¶ Performs Kolmogorov test.
Performs Kolmogorov test to check Gaussian assumption of the model (null hypothesis).
 Returns
 testResult
TestResult
Test result class.
 testResult
Notes
We check that the residual is Gaussian thanks to
FittingTest::Kolmogorov
.

getShadowedId
(self)¶ Accessor to the object’s shadowed id.
 Returns
 idint
Internal unique identifier.

getVisibility
(self)¶ Accessor to the object’s visibility state.
 Returns
 visiblebool
Visibility flag.

hasName
(self)¶ Test if the object is named.
 Returns
 hasNamebool
True if the name is not empty.

hasVisibleName
(self)¶ Test if the object has a distinguishable name.
 Returns
 hasVisibleNamebool
True if the name is not empty and not the default one.

setName
(self, name)¶ Accessor to the object’s name.
 Parameters
 namestr
The name of the object.

setShadowedId
(self, id)¶ Accessor to the object’s shadowed id.
 Parameters
 idint
Internal unique identifier.

setVisibility
(self, visible)¶ Accessor to the object’s visibility state.
 Parameters
 visiblebool
Visibility flag.