UnobservedComponents
UnobservedComponents forecasting model from statsmodels.
Quickstart
from sktime.forecasting.structural import UnobservedComponents
estimator = UnobservedComponents(level=False, trend=False, seasonal=None, freq_seasonal=None, cycle=False, autoregressive=None, irregular=False, stochastic_level=False, stochastic_trend=False, stochastic_seasonal=True, stochastic_freq_seasonal=None, stochastic_cycle=False, damped_cycle=False, cycle_period_bounds=None, mle_regression=True, use_exact_diffuse=False, start_params=None, transformed=True, includes_fixed=False, cov_type=None, cov_kwds=None, method='lbfgs', maxiter=50, full_output=1, disp=0, callback=None, return_params=False, optim_score=None, optim_complex_step=None, optim_hessian=None, flags=None, low_memory=False, random_state=None)Parameters(32)
- level{bool, str}, optional
- Whether or not to include a level component. Default is False. Can also be a string specification of the level / trend component.
- trendbool, optional
Whether or not to include a trend component. Default is False. If True,
levelmust also be True.- seasonal{int, None}, optional
- The period of the seasonal component, if any. Default is None.
- freq_seasonal{list[dict], None}, optional.
- Whether (and how) to model seasonal component(s) with trig. functions. If specified, there is one dictionary for each frequency-domain seasonal component. Each dictionary must have the key, value pair for ‘period’ – integer and may have a key, value pair for ‘harmonics’ – integer. If ‘harmonics’ is not specified in any of the dictionaries, it defaults to the floor of period/2.
- cyclebool, optional
- Whether or not to include a cycle component. Default is False.
- autoregressive{int, None}, optional
- The order of the autoregressive component. Default is None.
- irregularbool, optional
- Whether or not to include an irregular component. Default is False.
- stochastic_levelbool, optional
- Whether or not any level component is stochastic. Default is False.
- stochastic_trendbool, optional
- Whether or not any trend component is stochastic. Default is False.
- stochastic_seasonalbool, optional
- Whether or not any seasonal component is stochastic. Default is True.
- stochastic_freq_seasonallist[bool], optional
- Whether or not each seasonal component(s) is (are) stochastic. Default is True for each component. The list should be of the same length as freq_seasonal.
- stochastic_cyclebool, optional
- Whether or not any cycle component is stochastic. Default is False.
- damped_cyclebool, optional
- Whether or not the cycle component is damped. Default is False.
- cycle_period_boundstuple, optional
- A tuple with lower and upper allowed bounds for the period of the cycle. If not provided, the following default bounds are used: (1) if no date / time information is provided, the frequency is constrained to be between zero and \(\pi\), so the period is constrained to be in [0.5, infinity]. (2) If the date / time information is provided, the default bounds allow the cyclical component to be between 1.5 and 12 years; depending on the frequency of the endogenous variable, this will imply different specific bounds.
- mle_regressionbool, optional
- Whether or not to estimate regression coefficients by maximum likelihood as one of hyperparameters. Default is True. If False, the regression coefficients are estimated by recursive OLS, included in the state vector.
- use_exact_diffusebool, optional
- Whether or not to use exact diffuse initialization for non-stationary states. Default is False (in which case approximate diffuse initialization is used).
- start_paramsarray_like, optional
- Initial guess of the solution for the loglikelihood maximization.
- transformedbool, optional
Whether or not
start_paramsis already transformed. Default is True.- includes_fixedbool, optional
If parameters were previously fixed with the
fix_paramsmethod, this argument describes whether or notstart_paramsalso includes the fixed parameters, in addition to the free parameters. Default is False.- cov_typestr, optional
The
cov_typekeyword governs the method for calculating the covariance matrix of parameter estimates. Can be one of:‘opg’ for the outer product of gradient estimator
- ‘oim’ for the observed information matrix estimator, calculated
using the method of Harvey (1989)
- cov_kwdsdict or None, optional
A dictionary of arguments affecting covariance matrix computation. opg, oim, approx, robust, robust_approx
- ‘approx_complex_step’bool, optional - If True, numerical
approximations are computed using complex-step methods. If False, numerical approximations are computed using finite difference methods. Default is True.
- ‘approx_complex_step’bool, optional - If True, numerical
- methodstr, optional
The
methoddetermines which solver fromscipy.optimizeis used, and it can be chosen from among the following strings:‘newton’ for Newton-Raphson
‘nm’ for Nelder-Mead
‘bfgs’ for Broyden-Fletcher-Goldfarb-Shanno (BFGS)
‘lbfgs’ for limited-memory BFGS with optional box constraints
‘powell’ for modified Powell’s method
‘cg’ for conjugate gradient
‘ncg’ for Newton-conjugate gradient
‘basinhopping’ for global basin-hopping solver
The explicit arguments in
fitare passed to the solver, with the exception of the basin-hopping solver. Each solver has several optional arguments that are not the same across solvers. See the notes section below (or scipy.optimize) for the available arguments and for the list of explicit arguments that the basin-hopping solver supports.- maxiterint, optional
- The maximum number of iterations to perform.
- full_outputbool, optional
- Set to True to have all available output in the Results object’s mle_retvals attribute. The output is dependent on the solver. See LikelihoodModelResults notes section for more information.
- dispbool, optional
- Set to True to print convergence messages. Default is 0.
- callbackcallable callback(xk), optional
- Called after each iteration, as callback(xk), where xk is the current parameter vector.
- return_paramsbool, optional
- Whether or not to return only the array of maximizing parameters. Default is False.
- optim_score{‘harvey’, ‘approx’} or None, optional
The method by which the score vector is calculated. ‘harvey’ uses the method from Harvey (1989), ‘approx’ uses either finite difference or complex step differentiation depending upon the value of
optim_complex_step, and None uses the built-in gradient approximation of the optimizer. Default is None. This keyword is only relevant if the optimization method uses the score.- optim_complex_stepbool, optional
Whether or not to use complex step differentiation when approximating the score; if False, finite difference approximation is used. Default is True. This keyword is only relevant if
optim_scoreis set to ‘harvey’ or ‘approx’.- optim_hessian{‘opg’,’oim’,’approx’}, optional
- The method by which the Hessian is numerically approximated. ‘opg’ uses outer product of gradients, ‘oim’ uses the information matrix formula from Harvey (1989), and ‘approx’ uses numerical approximation. This keyword is only relevant if the optimization method uses the Hessian matrix.
- low_memorybool, optional
- If set to True, techniques are applied to substantially reduce memory usage. If used, some features of the results object will not be available (including smoothed results and in-sample prediction), although out-of-sample forecasting is possible. Default is False.
- random_stateint, RandomState instance or None, optional,
- default=None - If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.
Examples
>>> from sktime.datasets import load_airline
>>> from sktime.forecasting.structural import UnobservedComponents
>>> y = load_airline ()
>>> forecaster = UnobservedComponents (level = 'local linear trend')
>>> forecaster. fit (y) UnobservedComponents(
... )
>>> y_pred = forecaster. predict (fh = [1, 2, 3 ])References
- [1 ] Seabold, Skipper, and Josef Perktold. “statsmodels: Econometric and statistical modeling with python.” Proceedings of the 9th Python in Science Conference. 2010. [2 ] Durbin, James, and Siem Jan Koopman. 2012. Time Series Analysis by State Space Methods: Second Edition. Oxford University Press.