NaiveVariance
Compute the prediction variance based on a naive strategy.
NaiveVariance adds to a forecaster the ability to compute the prediction variance based on naive assumptions about the time series. The simple strategy is as follows: - Let \(y_1,\dots,y_T\) be the time series we fit the estimator \(f\) to. - Let \(\widehat{y}_{ij}\) be the forecast for time point \(j\), obtained from fitting the forecaster to the partial time series \(y_1,\dots,y_i\). - We compute the residuals matrix \(R=(r_{ij})=(y_j-\widehat{y}_{ij})\). - The variance prediction \(v_k\) for \(y_{T+k}\) is \(\frac{1}{T-k}\sum_{i=1}^{T-k} a_{i,i+k}^2\) because we are averaging squared residuals of all forecasts that are \(k\) time points ahead. - And for the covariance matrix prediction, the formula becomes \(Cov(y_k, y_l)=\frac{\sum_{i=1}^N \hat{r}_{k,k+i}*\hat{r}_{l,l+i}}{N}\).
- The resulting forecaster will implement
predict_interval,predict_quantiles,predict_var, andpredict_proba, even if the wrapped forecasterforecasterdid not have this capability; for point forecasts (predict), behaves like the wrapped forecaster.
Quickstart
from sktime.forecasting.naive import NaiveVariance
estimator = NaiveVariance(forecaster, initial_window=1, verbose=False)Parameters(3)
- forecasterestimator
- Estimator to which probabilistic forecasts are being added
- initial_windowint, optional, default=1
- number of minimum initial indices to use for fitting when computing residuals
- verbosebool, optional, default=False
- whether to print warnings if windows with too few data points occur
Examples
>>> from sktime.datasets import load_airline
>>> from sktime.forecasting.naive import NaiveForecaster, NaiveVariance
>>> y = load_airline ()
>>> forecaster = NaiveForecaster (strategy = "drift")
>>> variance_forecaster = NaiveVariance (forecaster)
>>> variance_forecaster. fit (y) NaiveVariance(
... )
>>> var_pred = variance_forecaster. predict_var (fh = [1, 2, 3 ])