segreg.model.OneBkptSegRegEstimator¶
- class OneBkptSegRegEstimator(num_end_to_skip=None, restrict_rhs_slope=None, no_bias_variance=False)[source]¶
Estimator for one-bkpt segmented regression.
This estimator is limited to univariate, continuous, linear, one-bkpt segmented regression problems. The model fitting estimates the parameters:
[u, v, m1, m2, sigma]
where
(u,v)
is the breakpoint (in x-y plane)m1
is the slope of the left-hand segmentm2
is the slope of the right-hand segmentsigma
is the standard deviation of the residualsExamples
>>> from segreg.model import OneBkptSegRegEstimator >>> indep = [1,2,3,4,5,6,7,8,9] >>> dep = [1,2,3,4,5,4,3,2,1] >>> estimator = OneBkptSegRegEstimator() >>> estimator.fit(indep, dep) array([ 5., 5., 1., -1., 0.])
- Parameters
num_end_to_skip (int) – Number of data points to skip at each end of the data when solving for the bkpts. As such, this determines a guaranteed minimum number of data points in the left and right segments in the returned fit. If None, defaults to the underlying implementation. TODO: explain
restrict_rhs_slope (float or None) – If not
None
, will fix the rhs slope,m2
, to the given value. As such, the rhs slopem2
will not be estimated whenfit
is called.no_bias_variance (bool) – If True, will modify the MLE estimate of the variance so that it is unbiased.
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.