本文整理汇总了Python中statsmodels.regression.linear_model.OLS.conf_int方法的典型用法代码示例。如果您正苦于以下问题:Python OLS.conf_int方法的具体用法?Python OLS.conf_int怎么用?Python OLS.conf_int使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类statsmodels.regression.linear_model.OLS
的用法示例。
在下文中一共展示了OLS.conf_int方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_conf_int_single_regressor
# 需要导入模块: from statsmodels.regression.linear_model import OLS [as 别名]
# 或者: from statsmodels.regression.linear_model.OLS import conf_int [as 别名]
def test_conf_int_single_regressor():
# GH#706 single-regressor model (i.e. no intercept) with 1D exog
# should get passed to DataFrame for conf_int
y = pandas.Series(np.random.randn(10))
x = pandas.Series(np.ones(10))
res = OLS(y, x).fit()
conf_int = res.conf_int()
np.testing.assert_equal(conf_int.shape, (1, 2))
np.testing.assert_(isinstance(conf_int, pandas.DataFrame))
示例2: test_706
# 需要导入模块: from statsmodels.regression.linear_model import OLS [as 别名]
# 或者: from statsmodels.regression.linear_model.OLS import conf_int [as 别名]
def test_706():
# make sure one regressor pandas Series gets passed to DataFrame
# for conf_int.
y = pandas.Series(np.random.randn(10))
x = pandas.Series(np.ones(10))
res = OLS(y,x).fit()
conf_int = res.conf_int()
np.testing.assert_equal(conf_int.shape, (1, 2))
np.testing.assert_(isinstance(conf_int, pandas.DataFrame))
示例3: UnivariateLinearModelAnalysis
# 需要导入模块: from statsmodels.regression.linear_model import OLS [as 别名]
# 或者: from statsmodels.regression.linear_model.OLS import conf_int [as 别名]
#.........这里部分代码省略.........
# Compute Box Cox if enabled
if self._boxCox:
if self._lambdaBoxCox is None:
# optimization required, get optimal lambda and graph
self._lambdaBoxCox, self._graphBoxCox = computeBoxCox(defects, signals)
# Transformation of data
boxCoxTransform = ot.BoxCoxTransform([self._lambdaBoxCox])
signals = boxCoxTransform(signals)
if self._noiseThres is not None:
noiseThres = boxCoxTransform([self._noiseThres])[0]
else:
noiseThres = self._noiseThres
if self._saturationThres is not None:
saturationThres = boxCoxTransform([self._saturationThres])[0]
else:
saturationThres = self._saturationThres
else:
noiseThres = self._noiseThres
saturationThres = self._saturationThres
######################### Linear Regression model ######################
# Linear regression with statsmodels module
# Create the X matrix : [1, inputSample]
X = ot.NumericalSample(defectsSize, [1, 0])
X[:, 1] = defects
self._algoLinear = OLS(np.array(signals), np.array(X)).fit()
self._resultsUnc.intercept = self._algoLinear.params[0]
self._resultsUnc.slope = self._algoLinear.params[1]
# get standard error estimates (residuals standard deviation)
self._resultsUnc.stderr = np.sqrt(self._algoLinear.scale)
# get confidence interval at level 95%
self._resultsUnc.confInt = self._algoLinear.conf_int(0.05)
if self._censored:
# define initial starting point for MLE optimization
initialStartMLE = [self._resultsUnc.intercept, self._resultsUnc.slope,
self._resultsUnc.stderr]
# MLE optimization
res = computeLinearParametersCensored(initialStartMLE, defects,
defectsNoise, defectsSat, signals, noiseThres, saturationThres)
self._resultsCens.intercept = res[0]
self._resultsCens.slope = res[1]
self._resultsCens.stderr = res[2]
############################ Residuals #################################
# get residuals from algoLinear
self._resultsUnc.residuals = ot.NumericalSample(np.vstack(self._algoLinear.resid))
# compute residuals distribution
self._resultsUnc.resDist = self._resDistFact.build(self._resultsUnc.residuals)
if self._censored:
# create linear model function for censored case
def CensLinModel(x):
return self._resultsCens.intercept + self._resultsCens.slope * x
# compute the residuals for the censored case.
self._resultsCens.fittedSignals = CensLinModel(defects)
self._resultsCens.residuals = signals - self._resultsCens.fittedSignals
# compute residuals distribution.
self._resultsCens.resDist = self._resDistFact.build(self._resultsCens.residuals)
########################## Compute tests ###############################
self._resultsUnc.testResults = \
self._computeTests(defects, signals, self._resultsUnc.residuals,