segreg.model.OLSRegressionEstimator¶
- class OLSRegressionEstimator[source]¶
Estimator for ordinary least-squares regression.
This estimator is limited to univariate, linear, regression problems. The model fitting estimates the parameters:
[intercept, slope, sigma]
where the fitted line is defined by
y =
intercept
+slope
* xand
sigma
is the standard deviation of the residuals.Notes
There are many standard python libraries for this type of OLS. This class is provided as a convenience to implement the same interface as the estimators for segmented regression. Moreover, the underlying implementation has been customized for the univariate regression problems for which this class is limited, for the purpose of greater calculation speed.
Examples
>>> from segreg.model import OLSRegressionEstimator >>> indep = [1,2,3,4,5] >>> dep = [2,3,4,5,6] >>> estimator = OLSRegressionEstimator() >>> estimator.fit(indep, dep) array([1., 1., 0.])
See also
Methods
fit
(indep, dep)Fit the model to the given data.
get_func_for_params
(params)Returns the regression model function defined by the given parameters.
Properties
Indices in the parameter array of the fitted parameters.
Whether there are any model parameters set to a fixed value.
Computes loglikelihood at the MLE (maximum likelihood estimate).
Returns the regression model function defined by the estimated parameters.
Number of model parameters.
Names of the parameters.
Returns the fitted parameters.
R-squared of the fit.
Returns the residuals from the fit.
Residual sum of squares of the fit.