Robyn icon indicating copy to clipboard operation
Robyn copied to clipboard

positivity constraint on season not respected

Open drbenvincent opened this issue 2 years ago • 4 comments

I am running a model with the following options

prophet_vars = c("trend", "season", "holiday"),
prophet_signs = c("positive", "positive", "positive"),

but when I examine pareto_alldecomp_matrix.csv (and just focus on a particular model of interest) then I see both positive and negative values. The positivity constraint does not seem to be applied.

I'd be grateful if you could confirm that this is a bug. If it is, I'd be even more grateful if it could be fixed.

Environment & Robyn version

R version 4.0.4 Robyn version 3.6.1 (installed by remotes::install_github('facebookexperimental/Robyn/R'))

drbenvincent avatar Mar 13 '22 18:03 drbenvincent

Checking the code, I don't see any obvious error or bug. I'll further run a hypothetical check without your data to reproduce this scenario first before I get back to you.. thanks for reporting it.

laresbernardo avatar Mar 14 '22 14:03 laresbernardo

Hey @drbenvincent We've internally discussed this specific case you mention and actually find it quite relevant. We think this is probably one of those very rare cases where it should probably be something only advanced users do and we generally try to discourage, given that forcing a sign for season/holiday logically may not make much sense in most scenarios. I'd also like to share with you this ticket where prophet's team discusses this matter with great detail and some illustrated examples. CC: @Leonelsentana @kyletgoldberg

laresbernardo avatar Mar 14 '22 15:03 laresbernardo

Thanks for that link @laresbernardo. I'll work through that - it looks to touch on issues I've been thinking about.

Just a bit more on the motivation... I'm trying to produce a contribution plot, as in a stacked area plot over time which decomposes the total predicted outcome variable over time into its various component parts. You could argue that (regardless of the implementation details) it would be appealing (and should be possible) to plot the contributions over time from each channel, intercept, trend, seasonality, etc.

So I'm a little uncertain at the moment if there is a working positivity constraint or not? But given that the seasonality component is producing positive and negative numbers that it's additive (not multiplicative). If so, I guess you might get positive only contributions from intercept+seasonality.

Either way, it should be possible to find the maths of the seasonality implementation (presumably in Prophet) that would allow generation of a contribution plot over time from the fitted parameters from Robyn.

drbenvincent avatar Mar 14 '22 16:03 drbenvincent

I observe the same issue. Training the model with the "positive" constrains to all prophet variables results in negative effects at the decomposition waterfall. Some models have negative season effect, some models have negative effect of holidays and weekday.

Robyn 3.6.3

DzimitryM avatar May 20 '22 18:05 DzimitryM

Please reopen if this issue reoccurs.

gufengzhou avatar Oct 28 '22 12:10 gufengzhou