Skip to content

Commit

Permalink
Merge pull request #6867 from bashtage/limit-var-order
Browse files Browse the repository at this point in the history
BUG: Limit maxlags in VAR
  • Loading branch information
bashtage committed Jul 9, 2020
2 parents f378da1 + efc7a7e commit cdad7de
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 148 deletions.
10 changes: 10 additions & 0 deletions docs/source/names_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,13 @@ Piet
Pelletier
Gentonb
Nychkac
Bańbura
Domenico
Elsevier
Escanciano
Giannone
Jacoby
Lobato
Lucrezia
Modugno
Reichlin
11 changes: 11 additions & 0 deletions docs/source/spelling_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2352,3 +2352,14 @@ lamda
parallelized
Jupyter
Reseasonalize
blobbogram
capstyle
dotplots
ldadjusted
linestyle
marginnames
nonsymmetric
Nowcasting
Seasonalities
substrings
ywadjusted
16 changes: 8 additions & 8 deletions statsmodels/graphics/dotplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def dot_plot(points, intervals=None, lines=None, sections=None,
styles_order : array_like
If stacked=True, this is the order in which the point styles
on a given line are drawn from top to bottom (if horizontal
is True) or from left to right (if horiontal is False). If
is True) or from left to right (if horizontal is False). If
None (default), the order is lexical.
striped : bool
If True, every other line is enclosed in a shaded box.
Expand Down Expand Up @@ -101,6 +101,13 @@ def dot_plot(points, intervals=None, lines=None, sections=None,
`points`, `intervals`, `lines`, `sections`, `styles` must all have
the same length whenever present.
References
----------
.. [1] Cleveland, William S. (1993). "Visualizing Data". Hobart Press.
.. [2] Jacoby, William G. (2006) "The Dot Plot: A Graphical Display
for Labeled Quantitative Values." The Political Methodologist
14(1): 6-14.
Examples
--------
This is a simple dotplot with one point per line:
Expand All @@ -112,13 +119,6 @@ def dot_plot(points, intervals=None, lines=None, sections=None,
the same line):
>>> dot_plot(points=point_values, lines=label_values)
References
----------
.. [1] Cleveland, William S. (1993). "Visualizing Data". Hobart Press.
.. [2] Jacoby, William G. (2006) "The Dot Plot: A Graphical Display
for Labeled Quantitative Values." The Political Methodologist
14(1): 6-14.
"""

import matplotlib.transforms as transforms
Expand Down
22 changes: 11 additions & 11 deletions statsmodels/imputation/mice.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,17 @@ class MICEData(object):
MICEData object is passed as the sole argument to
`history_callback`.
Notes
-----
Allowed perturbation methods are 'gaussian' (the model parameters
are set to a draw from the Gaussian approximation to the posterior
distribution), and 'boot' (the model parameters are set to the
estimated values obtained when fitting a bootstrapped version of
the data set).
`history_callback` can be implemented to have side effects such as
saving the current imputed data set to disk.
Examples
--------
Draw 20 imputations from a data set called `data` and save them in
Expand All @@ -179,17 +190,6 @@ class MICEData(object):
Impute using default models, using the MICEData object as an
iterator.
%(_mice_data_example_2)s
Notes
-----
Allowed perturbation methods are 'gaussian' (the model parameters
are set to a draw from the Gaussian approximation to the posterior
distribution), and 'boot' (the model parameters are set to the
estimated values obtained when fitting a bootstrapped version of
the data set).
`history_callback` can be implemented to have side effects such as
saving the current imputed data set to disk.
""" % {'_mice_data_example_1': _mice_data_example_1,
'_mice_data_example_2': _mice_data_example_2}

Expand Down
5 changes: 5 additions & 0 deletions statsmodels/tsa/mlemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ def loglike(self, params):
"""
Loglikelihood for timeseries model
Parameters
----------
params : array_like
The model parameters
Notes
-----
needs to be overwritten by subclass
Expand Down
10 changes: 5 additions & 5 deletions statsmodels/tsa/statespace/kalman_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ class KalmanFilter(Representation):
Keyword arguments may be used to provide default values for state space
matrices. See `Representation` for more details.
See Also
--------
FilterResults
statsmodels.tsa.statespace.representation.Representation
Notes
-----
There are several types of options available for controlling the Kalman
Expand Down Expand Up @@ -130,11 +135,6 @@ class KalmanFilter(Representation):
than explicit matrix inversion) is used. If only SOLVE_CHOLESKY had been
set, then the Cholesky decomposition method would *always* be used, even in
the case of 1-dimensional data.
See Also
--------
FilterResults
statsmodels.tsa.statespace.representation.Representation
"""

filter_methods = [
Expand Down
2 changes: 1 addition & 1 deletion statsmodels/tsa/statespace/kalman_smoother.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ def news(self, previous, t=None, start=None, end=None,
argument.
design : array, optional
Design matrix for the period `t` in time-varying models. If this
model has a time-varying design matrix, and the arugment `t` is out
model has a time-varying design matrix, and the argument `t` is out
of this model's sample, then a new design matrix for period `t`
must be provided. Unused otherwise.
Expand Down
103 changes: 54 additions & 49 deletions statsmodels/tsa/statespace/mlemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ class MLEModel(tsbase.TimeSeriesModel):
ssm : statsmodels.tsa.statespace.kalman_filter.KalmanFilter
Underlying state space representation.
See Also
--------
statsmodels.tsa.statespace.mlemodel.MLEResults
statsmodels.tsa.statespace.kalman_filter.KalmanFilter
statsmodels.tsa.statespace.representation.Representation
Notes
-----
This class wraps the state space model with Kalman filtering to add in
Expand All @@ -122,12 +128,6 @@ class MLEModel(tsbase.TimeSeriesModel):
The `start_params` `update` method must be overridden in the
child class (and the `transform` and `untransform` methods, if needed).
See Also
--------
statsmodels.tsa.statespace.mlemodel.MLEResults
statsmodels.tsa.statespace.kalman_filter.KalmanFilter
statsmodels.tsa.statespace.representation.Representation
"""

def __init__(self, endog, k_states, exog=None, dates=None, freq=None,
Expand Down Expand Up @@ -893,6 +893,11 @@ def loglike(self, params, *args, **kwargs):
Additional keyword arguments to pass to the Kalman filter. See
`KalmanFilter.filter` for more details.
See Also
--------
update : modifies the internal state of the state space model to
reflect new params
Notes
-----
[1]_ recommend maximizing the average likelihood to avoid scale issues;
Expand All @@ -903,11 +908,6 @@ def loglike(self, params, *args, **kwargs):
.. [1] Koopman, Siem Jan, Neil Shephard, and Jurgen A. Doornik. 1999.
Statistical Algorithms for Models in State Space Using SsfPack 2.2.
Econometrics Journal 2 (1): 107-60. doi:10.1111/1368-423X.00023.
See Also
--------
update : modifies the internal state of the state space model to
reflect new params
"""
transformed, includes_fixed, complex_step, kwargs = _handle_args(
MLEModel._loglike_param_names, MLEModel._loglike_param_defaults,
Expand Down Expand Up @@ -944,6 +944,10 @@ def loglikeobs(self, params, transformed=True, includes_fixed=False,
Additional keyword arguments to pass to the Kalman filter. See
`KalmanFilter.filter` for more details.
See Also
--------
update : modifies the internal state of the Model to reflect new params
Notes
-----
[1]_ recommend maximizing the average likelihood to avoid scale issues;
Expand All @@ -954,10 +958,6 @@ def loglikeobs(self, params, transformed=True, includes_fixed=False,
.. [1] Koopman, Siem Jan, Neil Shephard, and Jurgen A. Doornik. 1999.
Statistical Algorithms for Models in State Space Using SsfPack 2.2.
Econometrics Journal 2 (1): 107-60. doi:10.1111/1368-423X.00023.
See Also
--------
update : modifies the internal state of the Model to reflect new params
"""
params = self.handle_params(params, transformed=transformed,
includes_fixed=includes_fixed)
Expand Down Expand Up @@ -1608,16 +1608,16 @@ def transform_jacobian(self, unconstrained, approx_centered=False):
jacobian : ndarray
Jacobian matrix of the transformation, evaluated at `unconstrained`
See Also
--------
transform_params
Notes
-----
This is a numerical approximation using finite differences. Note that
in general complex step methods cannot be used because it is not
guaranteed that the `transform_params` method is a real function (e.g.
if Cholesky decomposition is used).
See Also
--------
transform_params
"""
return approx_fprime(unconstrained, self.transform_params,
centered=approx_centered)
Expand Down Expand Up @@ -2943,6 +2943,11 @@ def test_normality(self, method):
Jarque-Bera normality test. If None, an attempt is made to select
an appropriate test.
See Also
--------
statsmodels.stats.stattools.jarque_bera
The Jarque-Bera test of normality.
Notes
-----
Let `d` = max(loglikelihood_burn, nobs_diffuse); this test is
Expand All @@ -2952,11 +2957,6 @@ def test_normality(self, method):
data are missing completely at random. This test is then run on the
standardized residuals excluding those corresponding to missing
observations.
See Also
--------
statsmodels.stats.stattools.jarque_bera
The Jarque-Bera test of normality.
"""
if method is None:
method = 'jarquebera'
Expand Down Expand Up @@ -3171,17 +3171,17 @@ def test_serial_correlation(self, method, lags=None):
`statsmodels.stats.diagnostic.acorr_ljungbox`) for the `i` th
endogenous variable.
See Also
--------
statsmodels.stats.diagnostic.acorr_ljungbox
Ljung-Box test for serial correlation.
Notes
-----
Let `d` = max(loglikelihood_burn, nobs_diffuse); this test is
calculated ignoring the first `d` residuals.
Output is nan for any endogenous variable which has missing values.
See Also
--------
statsmodels.stats.diagnostic.acorr_ljungbox
Ljung-Box test for serial correlation.
"""
if method is None:
method = 'ljungbox'
Expand Down Expand Up @@ -3860,6 +3860,11 @@ def append(self, endog, exog=None, refit=False, fit_kwargs=None, **kwargs):
can be much faster if the original dataset is large), see the `extend`
method.
See Also
--------
statsmodels.tsa.statespace.mlemodel.MLEResults.extend
statsmodels.tsa.statespace.mlemodel.MLEResults.apply
Examples
--------
>>> index = pd.period_range(start='2000', periods=2, freq='A')
Expand Down Expand Up @@ -3893,11 +3898,6 @@ def append(self, endog, exog=None, refit=False, fit_kwargs=None, **kwargs):
>>> print(updated_res.forecast(1))
2003 0.878
Freq: A-DEC, dtype: float64
See Also
--------
statsmodels.tsa.statespace.mlemodel.MLEResults.extend
statsmodels.tsa.statespace.mlemodel.MLEResults.apply
"""
start = self.nobs
end = self.nobs + len(endog) - 1
Expand Down Expand Up @@ -3970,6 +3970,11 @@ def extend(self, endog, exog=None, fit_kwargs=None, **kwargs):
Updated Results object, that includes results only for the new
dataset.
See Also
--------
statsmodels.tsa.statespace.mlemodel.MLEResults.append
statsmodels.tsa.statespace.mlemodel.MLEResults.apply
Notes
-----
The `endog` argument to this method should consist of new observations
Expand Down Expand Up @@ -4013,11 +4018,6 @@ def extend(self, endog, exog=None, fit_kwargs=None, **kwargs):
>>> print(updated_res.forecast(1))
2003 0.878
Freq: A-DEC, dtype: float64
See Also
--------
statsmodels.tsa.statespace.mlemodel.MLEResults.append
statsmodels.tsa.statespace.mlemodel.MLEResults.apply
"""
start = self.nobs
end = self.nobs + len(endog) - 1
Expand Down Expand Up @@ -4076,6 +4076,11 @@ def apply(self, endog, exog=None, refit=False, fit_kwargs=None,
Updated Results object, that includes results only for the new
dataset.
See Also
--------
statsmodels.tsa.statespace.mlemodel.MLEResults.append
statsmodels.tsa.statespace.mlemodel.MLEResults.apply
Notes
-----
The `endog` argument to this method should consist of new observations
Expand Down Expand Up @@ -4117,11 +4122,6 @@ def apply(self, endog, exog=None, refit=False, fit_kwargs=None,
>>> print(new_res.forecast(1))
1983 1.1707
Freq: A-DEC, dtype: float64
See Also
--------
statsmodels.tsa.statespace.mlemodel.MLEResults.append
statsmodels.tsa.statespace.mlemodel.MLEResults.apply
"""
mod = self.model.clone(endog, exog=exog, **kwargs)
if copy_initialization:
Expand Down Expand Up @@ -4149,6 +4149,16 @@ def plot_diagnostics(self, variable=0, lags=10, fig=None, figsize=None):
If a figure is created, this argument allows specifying a size.
The tuple is (width, height).
Returns
-------
Figure
Figure instance with diagnostic plots
See Also
--------
statsmodels.graphics.gofplots.qqplot
statsmodels.graphics.tsaplots.plot_acf
Notes
-----
Produces a 2x2 plot grid with the following plots (ordered clockwise
Expand All @@ -4159,11 +4169,6 @@ def plot_diagnostics(self, variable=0, lags=10, fig=None, figsize=None):
with a Normal(0,1) density plotted for reference.
3. Normal Q-Q plot, with Normal reference line.
4. Correlogram
See Also
--------
statsmodels.graphics.gofplots.qqplot
statsmodels.graphics.tsaplots.plot_acf
"""
from statsmodels.graphics.utils import _import_mpl, create_mpl_fig
_import_mpl()
Expand Down
Loading

0 comments on commit cdad7de

Please sign in to comment.