Skip to content

Commit

Permalink
Merge pull request #326 from bashtage/std-resid-doc-results
Browse files Browse the repository at this point in the history
ENH/DOC: Add std_resid and improve result doc
  • Loading branch information
bashtage authored Nov 22, 2019
2 parents d219237 + a67eecd commit 6f4b4e4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
3 changes: 3 additions & 0 deletions arch/tests/univariate/test_mean.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ def test_ar(self):
res = ar.fit(disp=DISPLAY)
assert isinstance(res.resid, pd.Series)
assert isinstance(res.conditional_volatility, pd.Series)
std_resid = res.resid / res.conditional_volatility
std_resid.name = "std_resid"
assert_series_equal(res.std_resid, std_resid)
# Smoke bootstrap
summ = ar.fit(disp=DISPLAY).summary()
assert 'Constant Variance' in str(summ)
Expand Down
23 changes: 9 additions & 14 deletions arch/univariate/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,12 +872,6 @@ class ARCHModelFixedResult(_SummaryRepr):
Attributes
----------
loglikelihood : float
Value of the log-likelihood
params : Series
Estimated parameters
resid : {ndarray, Series}
nobs element array containing model residuals
model : ARCHModel
Model instance used to produce the fit
"""
Expand Down Expand Up @@ -1069,6 +1063,15 @@ def resid(self):
else:
return self._resid

@cached_property
def std_resid(self):
"""
Residuals standardized by conditional volatility
"""
std_res = self.resid / self.conditional_volatility
std_res.name = "std_resid"
return std_res

def plot(self, annualize=None, scale=None):
"""
Plot standardized residuals and conditional volatility
Expand Down Expand Up @@ -1404,14 +1407,6 @@ class ARCHModelResult(ARCHModelFixedResult):
Attributes
----------
loglikelihood : float
Value of the log-likelihood
params : Series
Estimated parameters
param_cov : DataFrame
Estimated variance-covariance of the parameters
resid : {ndarray, Series}
nobs element array containing model residuals
model : ARCHModel
Model instance used to produce the fit
"""
Expand Down
16 changes: 0 additions & 16 deletions doc/source/univariate/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,3 @@ using a simple model constructor.

.. currentmodule:: arch
.. autofunction:: arch_model


Model Results
=============
All model return the same object, a results class (:class:`ARCHModelResult`)

.. currentmodule:: arch.univariate.base
.. autoclass:: ARCHModelResult
:members: summary, forecast, conf_int, plot, hedgehog_plot, arch_lm_test

When using the ``fix`` method, a (:class:`ARCHModelFixedResult`) is produced
that lacks some properties of a (:class:`ARCHModelResult`) that are not
relevant when parameters are not estimated.

.. autoclass:: ARCHModelFixedResult
:members: summary, forecast, plot, hedgehog_plot, arch_lm_test
18 changes: 18 additions & 0 deletions doc/source/univariate/results.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Model Results
=============
All model return the same object, a results class (:class:`ARCHModelResult`).
When using the ``fix`` method, a (:class:`ARCHModelFixedResult`) is produced
that lacks some properties of a (:class:`ARCHModelResult`) that are not
relevant when parameters are not estimated.


.. module:: arch.univariate.base
:noindex:

.. currentmodule:: arch.univariate.base

.. autosummary::
:toctree: generated/

ARCHModelResult
ARCHModelFixedResult

0 comments on commit 6f4b4e4

Please sign in to comment.