1
$\begingroup$

I'm working on a timeseries that was significantly affected by the COVID-19 pandemic, but has since recovered to a more normal behavior. My objective is to have a good forecast for a couple of weeks, along with the use of regressor variables to simulate changes in a further stage, for this I'm using the statsmodel's SARIMAX package in python.

The series has a shape like this: enter image description here

As you can see, during the shutdown period the series loses the basic weekly variation it had and stays fairly flat until the shutdown stops. The main issue is that the shutdown period is skewing the coefficients when fitting the model. The options I've considered are the following:

  1. Use a Step regressor during the shutdown period.
  2. Remove the period entirely and consider that it 'never happened', this has the complication of yearly seasonality being lost.
  3. Adjusting the shutdown period to match the magnitude of pre-covid data.

What option would be the correct one? Is there another that I'm not considering?

$\endgroup$
5
  • 1
    $\begingroup$ You can add a variable say "Pandemic" which as value 1 during that period and 0 elsewhere. $\endgroup$ – user2974951 Oct 20 '20 at 8:15
  • $\begingroup$ I've added this variable and the coefficient appears to be not significant and the effect that it has on the model itself is negligible. Is there something I'm missing here? $\endgroup$ – Ignacio Valenzuela Oct 20 '20 at 8:41
  • $\begingroup$ How about Interaction with all other parameters? $\endgroup$ – cure Oct 20 '20 at 10:07
  • $\begingroup$ What do you mean with interaction? $\endgroup$ – Ignacio Valenzuela Oct 20 '20 at 15:07
  • $\begingroup$ Another possibility is to change the values in the shutdown period to values you think would have occurred had there been no shutdown. If you have any reasonable way to do that. $\endgroup$ – user54285 Oct 20 '20 at 22:33
0
$\begingroup$

I've been working on my own question and I can report the following results after trying all 3 options to the series in question. I've done a baseline model that just includes the regressor variable and tried the three approaches to this with the following validation:

  • The models are all tested with the same parameters in a ARIMAX model.
  • The test includes a walk-forward validation of 5 periods of 30 days each in the "after covid period"

The baseline model has a 19.88% MAPE over the 5 periods.

1. Use a Step regressor during the shutdown period.

I've introduced a variable into the model with a value of 1 during the shutdown period and 0 elsewhere. This was fairly easy to implement

df['shutdown'] = (df.index > pd.to_datetime('2020-03-06')) & (df.index < pd.to_datetime('2020-06-12')) == 1

I added this variable to the model and made an interaction with the other regressors and added it to my ARIMA model.

This approach yielded a 21.52% average MAPE over 5 periods in the walk forward validation.

It was also tested to add the regressor independently but the error was higher than the one initially tested.

2. Remove the period entirely and consider that it 'never happened'.

This approach was done by removing the shutdown period entirely and training the data where each observation had occurred a few months earlier, and then converting back to the original dates, of course this was also done for the regressor variables as well.

This yielded a result of 19.88% average MAPE over 5 periods in the walk forward validation, a fairly big performance improvement comparing it to the baseline model.

3. Adjusting the shutdown period to match the magnitude of pre-covid data.

To do this the series was adjusted with a multiplicator to reach the pre-covid levels. This was the worst of the options, because the scale and relation between the regressors and the dependent variable was lost. It didn't make sense to validate this model with the stepforward validation.

After all of this, a different approach was intended:

4. Adding COVID-19 information to the model: Number of active daily cases.

I got the data from Our World in Data COVID Datasetand after cleaning the series and smoothing it, I added the regressor with number of daily active cases to the model.

This yielded a result of 13.56% average MAPE over 5 periods in the walk forward validation, being this the best result and trimming a whole 6 percentage points from the error.

The conclusion here is that, at least in this case, there was a variable that was explaining the behavior both in the shotdown period and afterwards, and this provided the best result.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.