kats.models.var module¶
VAR forecasting Model
VAR model is a multivariate extension of the univariate autoregressive (AR) model. It captures the linear interdependencies between multiple variables using a system of equations. Each variable depends not only on its own lagged values but also on the lagged values of other variables. We use the implementation in statsmodels and re-write the API to adapt Kats development style.
Typical usage example:
params = VARParams() m = VARModel(data=TSData_multi, params=params) m.fit() res = m.predict(steps=30) m.plot()
- class kats.models.var.VARModel(data: kats.consts.TimeSeriesData, params: kats.models.var.VARParams)[source]¶
Bases:
Generic
[kats.models.model.ParamsType
]Model class for VAR
This class provides fit, predict, and plot methods for VAR model
- data¶
the input time series data as
kats.consts.TimeSeriesData
- params¶
the parameter class defined with VARParams
- static get_parameter_search_space() → List[Dict[str, Any]][source]¶
Provide a parameter space for VAR model
Move the implementation of get_parameter_search_space() out of var to avoid the massive dependencies of var and huge build size.
- predict(steps: int, include_history: bool = False, **kwargs) → Dict[str, kats.consts.TimeSeriesData][source]¶
Predict with the fitted VAR model
- Parameters
steps – Number of time steps to forecast
include_history – optional, A boolearn to specify whether to include historical data. Default is False.
freq – optional, frequency of timeseries data. Defaults to automatically inferring from time index.
alpha – optional, significance level of confidence interval. Defaults to 0.05
- Returns
Disctionary of predicted results for each metric. Each metric result has following columns: time, fcst, fcst_lower, and fcst_upper
- class kats.models.var.VARParams(**kwargs)[source]¶
Bases:
kats.consts.Params
Parameter class for VAR model
This is the parameter class for VAR forecasting model which stands for Vector Autoregressive Model.
- maxlags¶
Maximum number of lags to check for order selection, Defaults to 12 * (nobs/100.)**(1./4)
- method¶
Estimation method to use Defaults to OLS
- ic¶
Information criterion to use for VAR order selection Defaults to None
- trend¶
“c” - add constant (Default), “ct” - constant and trend, “ctt” - constant, linear and quadratic trend, “n”/“nc” - no constant, no trend