config-i1 / mes

Mixed Exponential Smoothing
0 stars 0 forks source link

Rewrite the seasonal part of the model #29

Open config-i1 opened 4 years ago

config-i1 commented 4 years ago

An example. When lags=c(7,365), instead of having two components with respective lags, it should be done as one component with lags=7 and another with lags = 365/7...

In the ideal world a model should have "monthly", "weekly" and "daily" components for this situation. Not clear, how to get there from lags=c(7,365)...

config-i1 commented 4 years ago

Don't rewrite the existing function, but see if an alternative can be developed based on that.

config-i1 commented 4 years ago

This involves a different state space structure: the function should look at the index of current observation and use the same index from the past in order to get the previous state. This will allow dealing with non-constant seasonalities.

config-i1 commented 4 years ago

This is relevant to m=24 because of the daylight saving and m=365 because of the leap years. The question is how to detect the change of indices in the data. Take from the y (e.g. zoo or POSIXct)? Or accept in lags somehow?

Potentially, this means that internally, instead of the vector of lags, we need to have a matrix, something like:

1 1 24 1 1 24 1 1 23 1 1 23 ... 1 1 24

config-i1 commented 4 years ago

What to do:

  1. Move the lagrows from C++ code to R,
  2. Make lagrows a matrix with lags, update C++ to deal with matrix,
  3. Amend the lagrows in the R code in order to reflect the changes in m for DST / Leap years.
config-i1 commented 4 years ago

Is it possible not to have a matrix for lagrows? Maybe have two variables: vector of lags and the matrix of lags. If the latter is not provided, then use the first one? This way we will save some space for cases, when the matrix is not needed.

config-i1 commented 4 years ago

Work in progress. Things to do:

  1. Introduce lagsCorrected matrix in the adamFitter and adam();
  2. Use the matrix in the adamForecaster() in C++
  3. Introduce it in adamSimulator() in C++
  4. Introduce lagsCorrected matrix in the forecast() method;
  5. The same stuff in adamErrorer(), CF() and rmultistep();
config-i1 commented 4 years ago

An alternative approach - abandon lags and use the seasonal profiles:

  1. Create a matrix with indices (e.g. when Monday happens in the data or when 22.00 is located);
  2. Use references to previous indices instead of lags;

In order to do this, the following things need to be updated in the code:

  1. adamFitter in C++;
  2. adamForecaster in C++;
  3. adamErrorer in C++;
  4. adamSimulator in C++;
  5. adamGeneral file with the checks;
  6. adam(), in the initialisation part.
config-i1 commented 4 years ago
  1. Recent and observed profiles are now introduced in a separate branch.
  2. adamFitter is done.

Things to add / change:

  1. Use recentProfileTable instead of matVt, when producing forecasts;
  2. Change obsStates to just obsInSample + maxLag, trim matVt for backcasting, as this is no longer needed;
  3. Do the other elements from the previous comment.
config-i1 commented 4 years ago

All done for the basic time series without the time stamps.