# UnivariateLinearModelAnalysis¶

class UnivariateLinearModelAnalysis(*args)

Linear regression analysis with residuals hypothesis tests.

Available constructors:

UnivariateLinearModelAnalysis(inputSample, outputSample)

UnivariateLinearModelAnalysis(inputSample, outputSample, noiseThres, saturationThres, resDistFact, boxCox)

Parameters
inputSample2-d sequence of float

Vector of the defect sizes, of dimension 1.

outputSample2-d sequence of float

Vector of the signals, of dimension 1.

noiseThresfloat

Value for low censored data. Default is None.

saturationThresfloat

Value for high censored data. Default is None.

resDistFactopenturns.DistributionFactory

Distribution hypothesis followed by the residuals. Default is openturns.NormalFactory.

boxCoxbool or float

Enable or not the Box Cox transformation. If boxCox is a float, the Box Cox transformation is enabled with the given value. Default is False.

Notes

This method automatically :

• computes the Box Cox parameter if boxCox is True,

• computes the transformed signals if boxCox is True or a float,

• builds the univariate linear regression model on the data,

• computes the linear regression parameters for censored data if needed,

• computes the residuals,

• runs all hypothesis tests.

Examples

Generate data :

>>> import openturns as ot
>>> import otpod
>>> N = 100
>>> ot.RandomGenerator.SetSeed(0)
>>> defectDist = ot.Uniform(0.1, 0.6)
>>> epsilon = ot.Normal(0, 1.9)
>>> defects = defectDist.getSample(N)
>>> signalsInvBoxCox = defects * 43. + epsilon.getSample(N) + 2.5
>>> invBoxCox = ot.InverseBoxCoxTransform(0.3)
>>> signals = invBoxCox(signalsInvBoxCox)


Run analysis with gaussian hypothesis on the residuals :

>>> analysis = otpod.UnivariateLinearModelAnalysis(defects, signals, boxCox=True)
>>> print analysis.getIntercept() # get intercept value
[Intercept for uncensored case : 2.51037]
>>> print analysis.getKolmogorovPValue()
[Kolmogorov p-value for uncensored case : 0.835529]


Run analysis with noise and saturation threshold :

>>> analysis = otpod.UnivariateLinearModelAnalysis(defects, signals, 60., 1700., boxCox=True)
>>> print analysis.getIntercept() # get intercept value for uncensored and censored case
[Intercept for uncensored case : 4.28758, Intercept for censored case : 3.11243]
>>> print analysis.getKolmogorovPValue()
[Kolmogorov p-value for uncensored case : 0.346827, Kolmogorov p-value for censored case : 0.885006]


Run analysis with a Weibull distribution hypothesis on the residuals

>>> analysis = otpod.UnivariateLinearModelAnalysis(defects, signals, 60., 1700., ot.WeibullFactory(), boxCox=True)
>>> print analysis.getIntercept() # get intercept value for uncensored and censored case
[Intercept for uncensored case : 4.28758, Intercept for censored case : 3.11243]
>>> print analysis.getKolmogorovPValue()
[Kolmogorov p-value for uncensored case : 0.476036, Kolmogorov p-value for censored case : 0.71764]


Methods

 drawBoxCoxLikelihood(self[, name]) Draw the loglikelihood versus the Box Cox parameter. drawLinearModel(self[, model, name]) Draw the linear regression prediction versus the true data. drawResiduals(self[, model, name]) Draw the residuals versus the defect values. drawResidualsDistribution(self[, model, name]) Draw the residuals histogram with the fitted distribution. drawResidualsQQplot(self[, model, name]) Draw the residuals QQ plot with the fitted distribution. Accessor to the Anderson Darling test p-value. Accessor to the Box Cox parameter. Accessor to the Breusch Pagan test p-value. Accessor to the Cramer Von Mises test p-value. Accessor to the Durbin Watson test p-value. Accessor to the Harrison McCabe test p-value. getInputSample(self) Accessor to the input sample. getIntercept(self) Accessor to the intercept of the linear regression model. Accessor to the Kolmogorov test p-value. Accessor to the noise threshold. Accessor to the output sample. getR2(self) Accessor to the R2 value. getResiduals(self) Accessor to the residuals. Accessor to the residuals distribution. getResults(self) Print results of the linear analysis. Accessor to the saturation threshold. getSlope(self) Accessor to the slope of the linear regression model. Accessor to the standard error of the estimate. Accessor to the Zero Mean test p-value. saveResults(self, name) Save all analysis test results in a file.
drawBoxCoxLikelihood(self, name=None)

Draw the loglikelihood versus the Box Cox parameter.

Parameters
namestring

name of the figure to be saved with transparent option sets to True and bbox_inches=’tight’. It can be only the file name or the full path name. Default is None.

Returns
figmatplotlib.figure

Matplotlib figure object.

axmatplotlib.axes

Matplotlib axes object.

Notes

This method is available only when the parameter boxCox is set to True.

drawLinearModel(self, model='uncensored', name=None)

Draw the linear regression prediction versus the true data.

Parameters
modelstring

The linear regression model to be used, either uncensored or censored if censored threshold were given. Default is uncensored.

namestring

name of the figure to be saved with transparent option sets to True and bbox_inches=’tight’. It can be only the file name or the full path name. Default is None.

Returns
figmatplotlib.figure

Matplotlib figure object.

axmatplotlib.axes

Matplotlib axes object.

drawResiduals(self, model='uncensored', name=None)

Draw the residuals versus the defect values.

Parameters
modelstring

The residuals to be used, either uncensored or censored if censored threshold were given. Default is uncensored.

namestring

name of the figure to be saved with transparent option sets to True and bbox_inches=’tight’. It can be only the file name or the full path name. Default is None.

Returns
figmatplotlib.figure

Matplotlib figure object.

axmatplotlib.axes

Matplotlib axes object.

drawResidualsDistribution(self, model='uncensored', name=None)

Draw the residuals histogram with the fitted distribution.

Parameters
modelstring

The residuals to be used, either uncensored or censored if censored threshold were given. Default is uncensored.

namestring

name of the figure to be saved with transparent option sets to True and bbox_inches=’tight’. It can be only the file name or the full path name. Default is None.

Returns
figmatplotlib.figure

Matplotlib figure object.

axmatplotlib.axes

Matplotlib axes object.

drawResidualsQQplot(self, model='uncensored', name=None)

Draw the residuals QQ plot with the fitted distribution.

Parameters
modelstring

The residuals to be used, either uncensored or censored if censored threshold were given. Default is uncensored.

namestring

name of the figure to be saved with transparent option sets to True and bbox_inches=’tight’. It can be only the file name or the full path name. Default is None.

Returns
figmatplotlib.figure

Matplotlib figure object.

axmatplotlib.axes

Matplotlib axes object.

getAndersonDarlingPValue(self)

Accessor to the Anderson Darling test p-value.

Returns
pValueopenturns.Point

Either the p-value for the uncensored case or for both cases.

getBoxCoxParameter(self)

Accessor to the Box Cox parameter.

Returns
lambdaBoxCoxfloat

The Box Cox parameter used to transform the data. If the transformation is not enabled None is returned.

getBreuschPaganPValue(self)

Accessor to the Breusch Pagan test p-value.

Returns
pValueopenturns.Point

Either the p-value for the uncensored case or for both cases.

getCramerVonMisesPValue(self)

Accessor to the Cramer Von Mises test p-value.

Returns
pValueopenturns.Point

Either the p-value for the uncensored case or for both cases.

getDurbinWatsonPValue(self)

Accessor to the Durbin Watson test p-value.

Returns
pValueopenturns.Point

Either the p-value for the uncensored case or for both cases.

getHarrisonMcCabePValue(self)

Accessor to the Harrison McCabe test p-value.

Returns
pValueopenturns.Point

Either the p-value for the uncensored case or for both cases.

getInputSample(self)

Accessor to the input sample.

Returns
defectsopenturns.Sample

The input sample which is the defect values.

getIntercept(self)

Accessor to the intercept of the linear regression model.

Returns
interceptopenturns.Point

The intercept parameter for the uncensored and censored (if so) linear regression model.

getKolmogorovPValue(self)

Accessor to the Kolmogorov test p-value.

Returns
pValueopenturns.Point

Either the p-value for the uncensored case or for both cases.

getNoiseThreshold(self)

Accessor to the noise threshold.

Returns
noiseThresfloat

The noise threhold if it exists, if not it returns None.

getOutputSample(self)

Accessor to the output sample.

Returns
signalsopenturns.Sample

The input sample which is the signal values.

getR2(self)

Accessor to the R2 value.

Returns
R2openturns.Point

Either the R2 for the uncensored case or for both cases.

getResiduals(self)

Accessor to the residuals.

Returns
residualsopenturns.Sample

The residuals computed from the uncensored and censored linear regression model. The first column corresponds with the uncensored case.

getResidualsDistribution(self)

Accessor to the residuals distribution.

Returns
distribution

The fitted distribution on the residuals, computed in the uncensored and censored (if so) case.

getResults(self)

Print results of the linear analysis.

getSaturationThreshold(self)

Accessor to the saturation threshold.

Returns
saturationThresfloat

The saturation threhold if it exists, if not it returns None.

getSlope(self)

Accessor to the slope of the linear regression model.

Returns
slopeopenturns.Point

The slope parameter for the uncensored and censored (if so) linear regression model.

getStandardError(self)

Accessor to the standard error of the estimate.

Returns
stderropenturns.Point

The standard error of the estimate for the uncensored and censored (if so) linear regression model.

getZeroMeanPValue(self)

Accessor to the Zero Mean test p-value.

Returns
pValueopenturns.Point

Either the p-value for the uncensored case or for both cases.

saveResults(self, name)

Save all analysis test results in a file.

Parameters
namestring

Name of the file or full path name.

Notes

The file can be saved as a csv file. Separations are made with tabulations.

If name is the file name, then it is saved in the current working directory.