I am trying to determine the influence that prior observations in a time series have on a forecasted value using exponential smoothing, i.e. the weights of the prior observations. For example, if I have a time series with 30 observations, and I forecast to time 34, I would like to determine the weight of observations 1-30 on the prediction for time 34.
I am using the ets() function in R, and letting the function determine the best model for the most part. I am fitting models to many different time series, most of which have a seasonality component.
Here is a code example:
> obs <- c(0.448, 0.63, 0.761, 0.904, 0.994, 1.122,
1.235, 1.29, 1.336, 1.396, 1.447, 1.518,
1.585, 1.602, 1.617, 1.528, 0.432, 0.571,
0.687, 0.81, 0.932, 1.006, 1.047, 1.106,
1.185, 1.248, 1.283, 1.323, 1.384, 1.404,
1.419, 1.375, 0.357, 0.498, 0.633, 0.739,
0.846, 0.936, 1.02, 1.103, 1.172, 1.238, 1.3, 1.358)
> ts_obj <- ts(obs, start=c(2015 , 1) , frequency = 16)
> fit <- ets(ts_obj, lambda = BoxCox.lambda(ts_obj))
> print(fit)
ETS(A,N,A)
Call:
ets(y = ts_obj, lambda = BoxCox.lambda(ts_obj))
Box-Cox transformation: lambda= -0.0012
Smoothing parameters:
alpha = 0.6842
gamma = 0.1166
Initial states:
l = 0.1642
s=0.3307 0.3667 0.3574 0.3359 0.296 0.25
0.2071 0.1673 0.1156 0.0623 -0.0284 -0.1294 -0.2724 -0.4426 -0.6466 -0.9695
sigma: 0.0205
AIC AICc BIC
-137.7304 -106.0637 -103.8308
> my_forecast <- forecast(fit, h = 4)
> print(my_forecast)
Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
2017.750 1.415694 1.379033 1.453332 1.360012 1.473660
2017.812 1.443549 1.398378 1.490180 1.375042 1.515473
2017.875 1.458954 1.406649 1.513206 1.379724 1.542739
2017.938 1.405555 1.349522 1.463919 1.320770 1.495790
Weights for prior observations must be calculated in order to get these forecasts, correct? Is there a way to extract them or compute them myself?
I have tried working out the algebra to do so using the equations given in Dr. Rob J Hyndman's and Dr. George Athanasopoulos's Forecasting: principles and practice free online textbook (which is great by the way). However, I have struggled because of the complexity of the recursion.
Thanks for the help in advance!