1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
|
.. module:: statsmodels.tsa
:synopsis: Time-series analysis
.. currentmodule:: statsmodels.tsa
.. _tsa:
Time Series analysis :mod:`tsa`
===============================
:mod:`statsmodels.tsa` contains model classes and functions that are useful
for time series analysis. Basic models include univariate autoregressive models (AR),
vector autoregressive models (VAR) and univariate autoregressive moving average models
(ARMA). Non-linear models include Markov switching dynamic regression and
autoregression. It also includes descriptive statistics for time series, for example autocorrelation, partial
autocorrelation function and periodogram, as well as the corresponding theoretical properties
of ARMA or related processes. It also includes methods to work with autoregressive and
moving average lag-polynomials.
Additionally, related statistical tests and some useful helper functions are available.
Estimation is either done by exact or conditional Maximum Likelihood or conditional
least-squares, either using Kalman Filter or direct filters.
Currently, functions and classes have to be imported from the corresponding module, but
the main classes will be made available in the statsmodels.tsa namespace. The module
structure is within statsmodels.tsa is
- stattools : empirical properties and tests, acf, pacf, granger-causality,
adf unit root test, kpss test, bds test, ljung-box test and others.
- ar_model : univariate autoregressive process, estimation with conditional
and exact maximum likelihood and conditional least-squares
- arima.model : univariate ARIMA process, estimation with alternative methods
- statespace : Comprehensive statespace model specification and estimation. See
the :ref:`statespace documentation <statespace>`.
- vector_ar, var : vector autoregressive process (VAR) and vector error correction
models, estimation, impulse response analysis, forecast error variance decompositions,
and data visualization tools. See the :ref:`vector_ar documentation <var>`.
- arma_process : properties of arma processes with given parameters, this
includes tools to convert between ARMA, MA and AR representation as well as
acf, pacf, spectral density, impulse response function and similar
- sandbox.tsa.fftarma : similar to arma_process but working in frequency domain
- tsatools : additional helper functions, to create arrays of lagged variables,
construct regressors for trend, detrend and similar.
- filters : helper function for filtering time series
- regime_switching : Markov switching dynamic regression and autoregression models
Some additional functions that are also useful for time series analysis are in
other parts of statsmodels, for example additional statistical tests.
Some related functions are also available in matplotlib, nitime, and
scikits.talkbox. Those functions are designed more for the use in signal
processing where longer time series are available and work more often in the
frequency domain.
.. currentmodule:: statsmodels.tsa
Descriptive Statistics and Tests
""""""""""""""""""""""""""""""""
.. autosummary::
:toctree: generated/
stattools.acovf
stattools.acf
stattools.pacf
stattools.pacf_yw
stattools.pacf_ols
stattools.pacf_burg
stattools.ccovf
stattools.ccf
stattools.adfuller
stattools.kpss
stattools.range_unit_root_test
stattools.zivot_andrews
stattools.coint
stattools.bds
stattools.q_stat
stattools.breakvar_heteroskedasticity_test
stattools.grangercausalitytests
stattools.levinson_durbin
stattools.innovations_algo
stattools.innovations_filter
stattools.levinson_durbin_pacf
stattools.arma_order_select_ic
x13.x13_arima_select_order
x13.x13_arima_analysis
Estimation
""""""""""
The following are the main estimation classes, which can be accessed through
statsmodels.tsa.api and their result classes
Univariate Autoregressive Processes (AR)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The basic autoregressive model in Statsmodels is:
.. currentmodule:: statsmodels.tsa
.. autosummary::
:toctree: generated/
ar_model.AutoReg
ar_model.AutoRegResults
ar_model.ar_select_order
The `ar_model.AutoReg` model estimates parameters using conditional MLE (OLS),
and supports exogenous regressors (an AR-X model) and seasonal effects.
AR-X and related models can also be fitted with the `arima.ARIMA` class and the
`SARIMAX` class (using full MLE via the Kalman Filter).
Autoregressive Moving-Average Processes (ARMA) and Kalman Filter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Basic ARIMA model and results classes are as follows:
.. currentmodule:: statsmodels.tsa
.. autosummary::
:toctree: generated/
arima.model.ARIMA
arima.model.ARIMAResults
This model allows estimating parameters by various methods (including
conditional MLE via the Hannan-Rissanen method and full MLE via the Kalman
filter). It is a special case of the `SARIMAX` model, and it includes a large
number of inherited features from the :ref:`state space <statespace>` models
(including prediction / forecasting, residual diagnostics, simulation and
impulse responses, etc.).
Exponential Smoothing
~~~~~~~~~~~~~~~~~~~~~
Linear and non-linear exponential smoothing models are available:
.. currentmodule:: statsmodels.tsa.holtwinters
.. autosummary::
:toctree: generated/
ExponentialSmoothing
SimpleExpSmoothing
Holt
HoltWintersResults
Separately, linear and non-linear exponential smoothing models have also been
implemented based on the "innovations" state space approach. In addition to the
usual support for parameter fitting, in-sample prediction, and out-of-sample
forecasting, these models also support prediction intervals, simulation, and
more.
.. currentmodule:: statsmodels.tsa
.. autosummary::
:toctree: generated/
exponential_smoothing.ets.ETSModel
exponential_smoothing.ets.ETSResults
Finally, linear exponential smoothing models have also been separately
implemented as a special case of the general state space framework (this is
separate from the "innovations" state space approach described above). Although
this approach does not allow for the non-linear (multiplicative) exponential
smoothing models, it includes all features of :ref:`state space <statespace>`
models (including prediction / forecasting, residual diagnostics, simulation
and impulse responses, etc.).
.. currentmodule:: statsmodels.tsa
.. autosummary::
:toctree: generated/
statespace.exponential_smoothing.ExponentialSmoothing
statespace.exponential_smoothing.ExponentialSmoothingResults
ARMA Process
""""""""""""
The following are tools to work with the theoretical properties of an ARMA
process for given lag-polynomials.
.. autosummary::
:toctree: generated/
arima_process.ArmaProcess
arima_process.ar2arma
arima_process.arma2ar
arima_process.arma2ma
arima_process.arma_acf
arima_process.arma_acovf
arima_process.arma_generate_sample
arima_process.arma_impulse_response
arima_process.arma_pacf
arima_process.arma_periodogram
arima_process.deconvolve
arima_process.index2lpol
arima_process.lpol2index
arima_process.lpol_fiar
arima_process.lpol_fima
arima_process.lpol_sdiff
.. currentmodule:: statsmodels.sandbox.tsa.fftarma
.. autosummary::
:toctree: generated/
ArmaFft
.. currentmodule:: statsmodels.tsa
Autoregressive Distributed Lag (ARDL) Models
""""""""""""""""""""""""""""""""""""""""""""
Autoregressive Distributed Lag models span the space between
autoregressive models (:class:`~statsmodels.tsa.ar_model.AutoReg`)
and vector autoregressive models (:class:`~statsmodels.tsa.vector_ar.VAR`).
.. currentmodule:: statsmodels.tsa
.. autosummary::
:toctree: generated/
ardl.ARDL
ardl.ARDLResults
ardl.ardl_select_order
ardl.ARDLOrderSelectionResults
The `ardl.ARDL` model estimates parameters using conditional MLE (OLS)
and allows for both simple deterministic terms (trends and seasonal
dummies) as well as complex deterministics using a
:class:`~statsmodels.tsa.deterministic.DeterministicProcess`.
AR-X and related models can also be fitted with
:class:`~statsmodels.tsa.statespace.sarimax.SARIMAX` class (using full MLE via
the Kalman Filter).
Error Correction Models (ECM)
"""""""""""""""""""""""""""""
Error correction models are reparameterizations of ARDL models that
regress the difference of the endogenous variable on the lagged levels
of the endogenous variables and optional lagged differences of the
exogenous variables.
.. currentmodule:: statsmodels.tsa
.. autosummary::
:toctree: generated/
ardl.UECM
ardl.UECMResults
ardl.BoundsTestResult
Statespace Models
"""""""""""""""""
See the :ref:`statespace documentation <statespace>`.
Vector ARs and Vector Error Correction Models
"""""""""""""""""""""""""""""""""""""""""""""
See the :ref:`vector_ar documentation. <var>`
Regime switching models
"""""""""""""""""""""""
.. currentmodule:: statsmodels.tsa.regime_switching.markov_regression
.. autosummary::
:toctree: generated/
MarkovRegression
.. currentmodule:: statsmodels.tsa.regime_switching.markov_autoregression
.. autosummary::
:toctree: generated/
MarkovAutoregression
Time Series Filters
"""""""""""""""""""
.. currentmodule:: statsmodels.tsa.filters.bk_filter
.. autosummary::
:toctree: generated/
bkfilter
.. currentmodule:: statsmodels.tsa.filters.hp_filter
.. autosummary::
:toctree: generated/
hpfilter
.. currentmodule:: statsmodels.tsa.filters.cf_filter
.. autosummary::
:toctree: generated/
cffilter
.. currentmodule:: statsmodels.tsa.filters.filtertools
.. autosummary::
:toctree: generated/
convolution_filter
recursive_filter
miso_lfilter
fftconvolve3
fftconvolveinv
.. currentmodule:: statsmodels.tsa.seasonal
.. autosummary::
:toctree: generated/
seasonal_decompose
STL
DecomposeResult
TSA Tools
"""""""""
.. currentmodule:: statsmodels.tsa.tsatools
.. autosummary::
:toctree: generated/
add_lag
add_trend
detrend
lagmat
lagmat2ds
VARMA Process
"""""""""""""
.. currentmodule:: statsmodels.tsa.varma_process
.. autosummary::
:toctree: generated/
VarmaPoly
Interpolation
"""""""""""""
.. currentmodule:: statsmodels.tsa.interp.denton
.. autosummary::
:toctree: generated/
dentonm
Deterministic Processes
"""""""""""""""""""""""
Deterministic processes simplify creating deterministic sequences with time
trend or seasonal patterns. They also provide methods to simplify generating
deterministic terms for out-of-sample forecasting. A
:class:`~statsmodels.tsa.deterministic.DeterministicProcess` can be directly
used with :class:`~statsmodels.tsa.ar_model.AutoReg` to construct complex
deterministic dynamics and to forecast without constructing exogenous trends.
.. currentmodule:: statsmodels.tsa.deterministic
.. autosummary::
:toctree: generated/
DeterministicProcess
TimeTrend
Seasonality
Fourier
CalendarTimeTrend
CalendarSeasonality
CalendarFourier
DeterministicTerm
CalendarDeterministicTerm
FourierDeterministicTerm
TimeTrendDeterministicTerm
Users who wish to write custom deterministic terms must subclass
:class:`~statsmodels.tsa.deterministic.DeterministicTerm`.
.. currentmodule:: statsmodels.tsa.deterministic
.. autosummary::
:toctree: generated/
DeterministicTerm
Forecasting Models
""""""""""""""""""
.. module:: statsmodels.tsa.forecasting
:synopsis: Models designed for forecasting
.. currentmodule:: statsmodels.tsa.forecasting
The Theta Model
~~~~~~~~~~~~~~~
The Theta model is a simple forecasting method that combines a linear time
trend with a Simple Exponential Smoother (Assimakopoulos & Nikolopoulos).
An estimator for the parameters of the Theta model and methods to forecast
are available in:
.. module:: statsmodels.tsa.forecasting.theta
:synopsis: Models designed for forecasting
.. currentmodule:: statsmodels.tsa.forecasting.theta
.. autosummary::
:toctree: generated/
ThetaModel
ThetaModelResults
Forecasting after STL Decomposition
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:class:`statsmodels.tsa.seasonal.STL` is commonly used to remove seasonal
components from a time series. The deseasonalized time series can then
be modeled using a any non-seasonal model, and forecasts are constructed
by adding the forecast from the non-seasonal model to the estimates of
the seasonal component from the final full-cycle which are forecast using
a random-walk model.
.. module:: statsmodels.tsa.forecasting.stl
:synopsis: Models designed for forecasting
.. currentmodule:: statsmodels.tsa.forecasting.stl
.. autosummary::
:toctree: generated/
STLForecast
STLForecastResults
Prediction Results
""""""""""""""""""
Most forecasting methods support a ``get_prediction`` method that return
a ``PredictionResults`` object that contains both the prediction, its
variance and can construct a prediction interval.
Results Class
~~~~~~~~~~~~~
.. module:: statsmodels.tsa.base.prediction
:synopsis: Shared objects for predictive methods
.. currentmodule:: statsmodels.tsa.base.prediction
.. autosummary::
:toctree: generated/
PredictionResults
|