当前位置: 首页>>代码示例>>Python>>正文


Python OLS.conf_int方法代码示例

本文整理汇总了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))
开发者ID:statsmodels,项目名称:statsmodels,代码行数:11,代码来源:test_regression.py

示例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))
开发者ID:NanoResearch,项目名称:statsmodels,代码行数:11,代码来源:test_regression.py

示例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,
开发者ID:adumasphi,项目名称:otpod,代码行数:70,代码来源:_univariate_linear_model_analysis.py


注:本文中的statsmodels.regression.linear_model.OLS.conf_int方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。