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.

Methods

drawBoxCoxLikelihood([name])

Draw the loglikelihood versus the Box Cox parameter.

drawLinearModel([model, name])

Draw the linear regression prediction versus the true data.

drawResiduals([model, name])

Draw the residuals versus the defect values.

drawResidualsDistribution([model, name])

Draw the residuals histogram with the fitted distribution.

drawResidualsQQplot([model, name])

Draw the residuals QQ plot with the fitted distribution.

getAndersonDarlingPValue()

Accessor to the Anderson Darling test p-value.

getBoxCoxParameter()

Accessor to the Box Cox parameter.

getBreuschPaganPValue()

Accessor to the Breusch Pagan test p-value.

getCramerVonMisesPValue()

Accessor to the Cramer Von Mises test p-value.

getDurbinWatsonPValue()

Accessor to the Durbin Watson test p-value.

getHarrisonMcCabePValue()

Accessor to the Harrison McCabe test p-value.

getInputSample()

Accessor to the input sample.

getIntercept()

Accessor to the intercept of the linear regression model.

getKolmogorovPValue()

Accessor to the Kolmogorov test p-value.

getNoiseThreshold()

Accessor to the noise threshold.

getOutputSample()

Accessor to the output sample.

getR2()

Accessor to the R2 value.

getResiduals()

Accessor to the residuals.

getResidualsDistribution()

Accessor to the residuals distribution.

getResults()

Print results of the linear analysis.

getSaturationThreshold()

Accessor to the saturation threshold.

getSlope()

Accessor to the slope of the linear regression model.

getStandardError()

Accessor to the standard error of the estimate.

getZeroMeanPValue()

Accessor to the Zero Mean test p-value.

saveResults(name)

Save all analysis test results in a file.

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.WeibullMinFactory(), 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]
drawBoxCoxLikelihood(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(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(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(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(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()

Accessor to the Anderson Darling test p-value.

Returns:
pValueopenturns.Point

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

getBoxCoxParameter()

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()

Accessor to the Breusch Pagan test p-value.

Returns:
pValueopenturns.Point

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

getCramerVonMisesPValue()

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()

Accessor to the Durbin Watson test p-value.

Returns:
pValueopenturns.Point

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

getHarrisonMcCabePValue()

Accessor to the Harrison McCabe test p-value.

Returns:
pValueopenturns.Point

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

getInputSample()

Accessor to the input sample.

Returns:
defectsopenturns.Sample

The input sample which is the defect values.

getIntercept()

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()

Accessor to the Kolmogorov test p-value.

Returns:
pValueopenturns.Point

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

getNoiseThreshold()

Accessor to the noise threshold.

Returns:
noiseThresfloat

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

getOutputSample()

Accessor to the output sample.

Returns:
signalsopenturns.Sample

The input sample which is the signal values.

getR2()

Accessor to the R2 value.

Returns:
R2openturns.Point

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

getResiduals()

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()

Accessor to the residuals distribution.

Returns:
distributionlist of openturns.Distribution

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

getResults()

Print results of the linear analysis.

getSaturationThreshold()

Accessor to the saturation threshold.

Returns:
saturationThresfloat

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

getSlope()

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()

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()

Accessor to the Zero Mean test p-value.

Returns:
pValueopenturns.Point

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

saveResults(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.