Replies: 4 comments 1 reply
-
I like the idea of adding competitor effect! Before diving into the code, I have some questions.
How to calculate the y_pred considering also the effect of the media competitors?
Your mdip_comp factors are not negative, 100^(-0.05) is a positive number. |
Beta Was this translation helpful? Give feedback.
-
Happy that you like the idea! I will better specify the variables I used. In the First Model, I added the competitor promo as negative (X3): this is for helping to calculate the base_sales. In the Second Model, I don't get why should I to consider them positive?
|
Beta Was this translation helpful? Give feedback.
-
My thoughts...
I saw agencies/papers always use competition as control variable. I haven't dealt with competitors data (I did MMM in-house), so I feel not competent to give instructions on this. It's unconventional to use them as focal variables, I can't tell it's a good or bad practice, you're free to try. I'm interested in your result. Computing media contribution y = baseline * x1^b1 * x2^b2 baseline=1000 About code:
(Sorry I don't have time to follow chunks of code, I only looked at these problematic lines you highlighted.) |
Beta Was this translation helpful? Give feedback.
-
Hi Sibyl, I did this little modification, inside the mmm_decompose_contrib.
Really thank you for your suggestions and help! |
Beta Was this translation helpful? Give feedback.
-
Hi Sibyl,
Sorry I thought to asnwer you about this question.
"Why do you want to avoid 0's, or what's your purpose for changing the adstock? I don't understand your problem and goal, if you let me know, I might have more specific answer" At the end you were right, it didn't change anything. So it's correct to leave the code like this.
I am sharing some chunks of the code that I added/modified, hoping they can be helpful.
Here I add a new part for the First Model to have the R2 and the AdjR2 (I don't know how much can be helpful, but I hope a little bit). Just plug at the end of the Stan Code.
###FIRST MODEL
###STAN CODE
In the Second Model, I plugged into it a new chunk to have also the media competitors effect (forced as negative). I create a new matrix Z and for it a specific peak and decay. In addition is possible to see also distribution beta for them.
However, I don't know if this is out of the scope of your publication.
Regarding this second step, I have one question. As you can see, I am calculating the y_pred like this:
y_pred = factor_df.drop(mdip_comp_cols, axis =1).apply(np.prod, axis=1)
where "mdip_comp_cols" are the columns of the media competitors. I did this to avoid the negative values since I calculated the beta competitors like this:
Do you know how to calculate the y_pred considering also the effect of the media competitors?
In addition I tried to take it out the R2 and the AdjR2 without having results. At the same time I don't know how much can be helpful to have it. Eventually, in this code I didn't consider the mc_delta for the proportion.
Here you can find the code. I started from the starting point of Second Model because there are many steps in between.
It is only necessary to create this in the first lines of the importing phase also because it is necessary to use them to check for multicollinearity among media:
mdip_comp_cols = [col for col in df.columns if 'atl_' in col]
###FIRST MODEL
###STAN CODE
###FITTING AND EXTRAPOLATION FEATURES
###BETA PLOT
###BETA COMP
###MEDIA CONTRIBUTION
###calculate media contribution percentage
As always thank you for your help, hoping these modifications can be helpful or at least interesting
Beta Was this translation helpful? Give feedback.
All reactions