prophet icon indicating copy to clipboard operation
prophet copied to clipboard

Can prophet accommodate multiplicative seasonality/holiday effects?

Open cebnesaj opened this issue 9 years ago • 12 comments

Is there a way to specify day of the week/holiday effects to be interacted with the overall trend i.e. as the trend level gets higher, the effects of a given day of the week or a holiday also get larger so the effect is proportional rather than absolute/constant? Basically, I have data that exhibits increasing amplitude over time as the average level increases, and while the default prophet model will model things well on average, it doesn't do well on a given day.

cebnesaj avatar Jul 17 '17 23:07 cebnesaj

@cebnesaj log transformation?

mucun1988 avatar Jul 18 '17 01:07 mucun1988

I tried all the usual techniques for dealing with heteroskedastic data. And for more clarity, my concern is to improve forecasting, not about standard errors or anything. Being able to have day effects vary with time would help that.

cebnesaj avatar Jul 18 '17 01:07 cebnesaj

What you describe is multiplicative seasonality. Prophet uses an additive seasonality model. You can get multiplicative seasonality by taking the log of your data (and then exponentiating the forecast) - sometimes this works well other times it doesn't, because it changes the trend model also. #264 adds multiplicative seasonality, so try it out and hopefully it will be integrated soon.

bletham avatar Jul 30 '17 01:07 bletham

Thanks for your reply! I initially had the same thought about logging the outcome variable, but the forecast error did not improve much, likely for the reason you point out. A linear main effect + seasonality interaction is really what would fit my data perfectly, so I'll definitely try out the new enhancement and look forward to it being integrated into the package.

cebnesaj avatar Jul 31 '17 17:07 cebnesaj

Multiplicative seasonality is now in the v0.3 branch. If anyone would like to test it out I'd appreciate the feedback.

In Python: remove the current version of prophet with pip3 uninstall fbprophet, download the v0.3 branch from https://github.com/facebook/prophet/tree/v0.3, cd into the python directory and run python3 setup.py install. m = Prophet(seasonality_mode='multiplicative') will enable multiplicative seasonality.

In R: run

devtools::install_github('facebook/prophet', subdir='R', ref='v0.3')

and then m <- prophet(seasonality.mode = 'multiplicative') will enable multiplicative seasonality.

bletham avatar May 16 '18 20:05 bletham

image

I am getting above error. I was not getting this error before.

Can you please help clarify? Do I have to install visual basic tools with the new version? Deniz

denizn avatar May 25 '18 09:05 denizn

This issue would be coming from pystan. I wonder if perhaps pystan was upgraded to a higher version? Or maybe you have previously used pystan inside conda but are now trying to install pystan outside of conda? You can see that pystan is not working with:

import pystan
model_code = 'parameters {real y;} model {y ~ normal(0,1);}'
model = pystan.StanModel(model_code=model_code)  # this will take a minute
y = model.sampling(n_jobs=1).extract()['y']
y.mean()  # should be close to 0

bletham avatar May 25 '18 17:05 bletham

Is it normal that it displays a message "Dependencies for version 0.2.1 are loaded" when I actually install the setup.py on the v3?

denizn avatar May 28 '18 03:05 denizn

Yes, all the version references are still on 0.2.1. in the 0.3 branch.

ghost avatar May 28 '18 07:05 ghost

Hi! I am currently trying out 0.3 branch.

It does behave significantly different than 0.2.1.

Can you please help me with what is the "default" mode for regressors and seasonality? Also, do we have an option to change trend to anything else than "linear" or "logistic?

my forecasts seem to grow EXTREMELY fast and I would like to dampen them: however, logistic doesnt seem to work for me.

Thank you, Deniz

denizn avatar May 29 '18 05:05 denizn

The default mode for regressors and seasonalities is whatever the seasonality_mode is set to on model initialization, which defaults to additive.

Setting a cap for logistic growth will force the forecast to saturate at that value; let's discuss on another issue if that is not behaving the way you expect, just to keep this issue about the multiplicative seasonality.

bletham avatar May 29 '18 16:05 bletham

This is now out in v0.3, as described in the documentation here: https://facebook.github.io/prophet/docs/multiplicative_seasonality.html

bletham avatar Jun 07 '18 18:06 bletham