facebookexperimental / Robyn

Robyn is an experimental, AI/ML-powered and open sourced Marketing Mix Modeling (MMM) package from Meta Marketing Science. Our mission is to democratise modeling knowledge, inspire the industry through innovation, reduce human bias in the modeling process & build a strong open source marketing science community.
https://facebookexperimental.github.io/Robyn/
MIT License
1.07k stars 322 forks source link

Plot Weibull PDF Adstock and get the peak value time point #901

Closed DongHarry-Kang closed 5 months ago

DongHarry-Kang commented 5 months ago

I am recently trying to identify the peak value of Weibull PDF adstock for my Robyn result such as below. Could somebody share the code how to obtain the time point that each curve becomes peak? looping in @gufengzhou for your opinion. thanks! image

I tried the below code to recreate, but the I noticed the time point shifted to the left. (I tried to recreate #1 graph). could somebody tell me how to do this correctly? library(Robyn) library(ggplot2)

install.packages("data.table") library(data.table) x = rep(1, 150) wb_out <- adstock_weibull(x=x, shape = 5.8148618518, scale = 0.0919861, type = "pdf") dt_plot <- data.table(ds = 1:150, x_accum_decay = wb_out$thetaVecCum) ggplot(dt_plot, aes(x=ds, y=x_accum_decay)) + geom_line()

image

gufengzhou commented 5 months ago

In your 1st plot, what's the x axis? the onepager plot for weibull adstock has cut the x-axis shorter for better readability, see here.

DongHarry-Kang commented 5 months ago

Hi @gufengzhou , I realized as long as I set the x-axis as the same # of timepoints as my sample, I can get the same results. I will close this issue