コード例 #1
0
ファイル: ar_model.py プロジェクト: jbrockmendel/sm2
        # TODO: return forecast errors and confidence intervals
        #from sm2.tsa.arima_process import arma2ma
        #ma_rep = arma2ma(np.r_[1,-params[::-1]], [1], out_of_sample)
        #fcasterr = np.sqrt(self.sigma2 * np.cumsum(ma_rep**2))

    preddoc = AR.predict.__doc__.split('\n')
    extra_doc = ("""        confint : bool, float
            Whether to return confidence intervals.  If `confint` == True,
            95 % confidence intervals are returned.  Else if `confint` is a
            float, then it is assumed to be the alpha value of the confidence
            interval.  That is confint == .05 returns a 95% confidence
            interval, and .10 would return a 90% confidence interval."""
                 ).split('\n')
    #ret_doc = """
    #    fcasterr : array-like
    #    confint : array-like
    #"""
    predict.__doc__ = '\n'.join(preddoc[:5] + preddoc[7:20] + extra_doc +
                                preddoc[20:])
    # TODO: is the docstring inaccurate?  It looks like confint isnt returned


class ARResultsWrapper(wrap.ResultsWrapper):
    _attrs = {}
    _wrap_attrs = wrap.union_dicts(
        tsa_model.TimeSeriesResultsWrapper._wrap_attrs, _attrs)
    _methods = {}
    _wrap_methods = wrap.union_dicts(
        tsa_model.TimeSeriesResultsWrapper._wrap_methods, _methods)
wrap.populate_wrapper(ARResultsWrapper, ARResults)  # noqa:E305
コード例 #2
0
    filter_results : HamiltonFilterResults or KimSmootherResults instance
        The underlying filter and, optionally, smoother output
    cov_type : string
        The type of covariance matrix estimator to use. Can be one of 'approx',
        'opg', 'robust', or 'none'.

    Attributes
    ----------
    model : Model instance
        A reference to the model that was fit.
    filter_results : HamiltonFilterResults or KimSmootherResults instance
        The underlying filter and, optionally, smoother output
    nobs : float
        The number of observations used to fit the model.
    params : array
        The parameters of the model.
    scale : float
        This is currently set to 1.0 and not used by the model or its results.
    """
    pass


class MarkovRegressionResultsWrapper(
        markov_switching.MarkovSwitchingResultsWrapper):
    pass


wrap.populate_wrapper(
    MarkovRegressionResultsWrapper,  # noqa:E305
    MarkovRegressionResults)
コード例 #3
0
ファイル: tsa_model.py プロジェクト: jbrockmendel/sm2
        # TODO: I don't like that self.data is mutable
        return self.data.xnames

    @exog_names.setter
    def exog_names(self, vals):
        # overwrite with writable property for (V)AR models
        if not isinstance(vals, list):
            vals = [vals]
        self.data.xnames = vals


class TimeSeriesModelResults(base.LikelihoodModelResults):
    def __init__(self, model, params, normalized_cov_params, scale=1.):
        self.data = model.data
        super(TimeSeriesModelResults,
              self).__init__(model, params, normalized_cov_params, scale)


class TimeSeriesResultsWrapper(wrap.ResultsWrapper):
    _attrs = {}
    _wrap_attrs = wrap.union_dicts(base.LikelihoodResultsWrapper._wrap_attrs,
                                   _attrs)
    _methods = {'predict': 'dates'}
    _wrap_methods = wrap.union_dicts(
        base.LikelihoodResultsWrapper._wrap_methods, _methods)


wrap.populate_wrapper(
    TimeSeriesResultsWrapper,  # noqa:E305
    TimeSeriesModelResults)
コード例 #4
0
ファイル: elastic_net.py プロジェクト: jbrockmendel/sm2
    else:
        return np.nan

    # If the new point is not uphill for the target function, take it
    # and return.  This check is a bit expensive and un-necessary for
    # OLS
    if not check_step:
        return x + h

    f1 = func(x + h, model) + L1_wt * np.abs(x + h)
    if f1 <= f + L1_wt * np.abs(x) + 1e-10:
        return x + h

    # Fallback for models where the loss is not quadratic
    from scipy.optimize import brent
    x_opt = brent(func, args=(model,), brack=(x - 1, x + 1), tol=tol)
    return x_opt


class RegularizedResults(Results):
    pass


class RegularizedResultsWrapper(wrap.ResultsWrapper):
    _attrs = {'params': 'columns',
              'resid': 'rows',
              'fittedvalues': 'rows'}
    _wrap_attrs = _attrs
wrap.populate_wrapper(RegularizedResultsWrapper,  # noqa:E305
                      RegularizedResults)
コード例 #5
0
ファイル: count_model.py プロジェクト: jbrockmendel/sm2
class L1ZeroInflatedNegativeBinomialResults(L1CountResults,
                                            ZeroInflatedNegativeBinomialResults
                                            ):  # noqa:E128
    pass


# -------------------------------------------------------------
# Wrapper Classes


class ZeroInflatedPoissonResultsWrapper(lm.RegressionResultsWrapper):
    pass


wrap.populate_wrapper(
    ZeroInflatedPoissonResultsWrapper,  # noqa:E305
    ZeroInflatedPoissonResults)


class L1ZeroInflatedPoissonResultsWrapper(lm.RegressionResultsWrapper):
    pass


wrap.populate_wrapper(
    L1ZeroInflatedPoissonResultsWrapper,  # noqa:E305
    L1ZeroInflatedPoissonResults)


class ZeroInflatedGeneralizedPoissonResultsWrapper(lm.RegressionResultsWrapper
                                                   ):
    pass
コード例 #6
0
        smry = Summary()
        smry.add_table_2cols(self,
                             gleft=top_left,
                             gright=top_right,
                             yname=yname,
                             xname=xname,
                             title=title)
        smry.add_table_params(self,
                              yname=yname,
                              xname=xname,
                              alpha=alpha,
                              use_t=self.use_t)

        # add warnings/notes, added to text format only
        etext = []
        wstr = ("If the model instance has been used for another "
                "fit with different fit\n"
                "parameters, then the fit options might not be the "
                "correct ones anymore .")
        etext.append(wstr)
        if etext:
            smry.add_extra_txt(etext)
        return smry


class RLMResultsWrapper(lm.RegressionResultsWrapper):
    pass


wrap.populate_wrapper(RLMResultsWrapper, RLMResults)  # noqa:E305