Power BI, R and Marketing Campaign Analysis

For the second post in a row, I’m going to talk about casino performance analysis so I’m feeling a little like Marty McFly from Back to the Future. One of the biggest struggles we had was with our direct mail offers to our players’ club members. A proper direct mail offer campaign would be setup with a control group so we could perform analysis against the control group, but try to tell that to the A tier player that didn’t get an offer or a different amount then the other A tier players.

Without the control group, we would calculate the difference between the average coin in before and after the direct mail offer was received to judge our incremental revenue and evaluate whether the campaign was successful. This method was very simplistic because it assumed all differences between performance before and after the interaction are due strictly to that direct mail offer. Google set out to help digital marketers with this problem of no control group in 2014 and we can use their Causal Impact R package to analyze our casino’s direct mail offers as well.

Putting it All to Use

Using the same daily Coin in (gross sales) data from the last blog on “Use Power BI and R to Quickly Identify Business Insights”, we need to complete the following steps:

  1. Install the following R packages
    1. install.packages(“devtools”)
    2. install.packages(“BoomSpikeSlab”)
    3. install.packages(“dtw”)
    4. install.packages(“chron”)
    5. devtools::install_github(“google/CausalImpact”)
  2. In Power BI Desktop, select the “R” in the Visualizations section and then drag the Denomination, Date and Revenue fields from the Coin In tables into the Values section to build our dataset for are R code.

Power BI Desktop

3. Add the following code in the R Script editor

library(CausalImpact)

library(data.table)

productsM <- melt(dataset, id=1:2)

productsC <- dcast(productsM, Date ~ Denomination + variable, sum)

colnames(productsC) <- make.names(colnames(productsC))

products <- zoo(productsC[,2:ncol(productsC)],as.Date(productsC[,1]))

pre.period <- as.Date(c(“2008-01-01”, “2008-10-03”))

post.period <- as.Date(c(“2008-10-04”, “2008-11-15”))

impact <- CausalImpact(products, pre.period, post.period, model.args=list(nseasons=7))

plot(impact)

#summary(impact)

4. Click the run button to execute the R script

Power BI R Script

Understanding the Results

The Casual Impact R package reduces the below three graphs

Original: Solid, black line is observed data before the intervention and dotted, blue line is the predicted coin in values for what would have occurred without the intervention

Pointwise: The net difference between the observed and predicted response on the original scale, or the difference between the solid, black line and the dotted, blue line on the original graph.

Cumulative: Dotted, blue line is the individual causal effects added up in time, day after day.

For all three graphs, the light blue shaded area represents the results in a 95% confidence level. The farther that the graph extends past the beginning of the intervention, the less certain of the causal effect; hence, the larger the shaded area.Power BI R visualization

Conclusion

Hope this helps you with your marketing campaign analysis in your organization.

Use Power BI and R to Quickly Identify Business Insights

In statistics, the correlation coefficient or Pearson’s correlation is a measure the strength and direction of association that exists between two continuous variables. The value of correlation, r, is always between +1 and –1. To interpret its value, see which of the following values your correlation r is closest to:

  • Exactly 1. A perfect downhill (negative) linear relationship
  • 0.70. A strong downhill (negative) linear relationship
  • 0.50. A moderate downhill (negative) relationship
  • 0.30. A weak downhill (negative) linear relationship
  • 0. No linear relationship
  • +0.30. A weak uphill (positive) linear relationship
  • +0.50. A moderate uphill (positive) relationship
  • +0.70. A strong uphill (positive) linear relationship
  • Exactly +1. A perfect uphill (positive) linear relationship

Don’t make the mistake of thinking that a correlation of –1 is a bad thing, indicating no relationship. Just the opposite is true! A correlation of –1 means the data are lined up in a perfect straight line, the strongest negative linear relationship you can get. The “–” (minus) sign just happens to indicate a negative relationship, a downhill line. Most statisticians like to see correlations beyond at least +0.5 or –0.5 before drawing any conclusions. Additional information on Pearson’s correlation can be found here.

Putting it All to Use

This is all great knowledge, but how can we apply this in a business environment. When I worked for a casino, we kept a daily record of Coin In (gross sales), High Temp, Low Temp and Fuel price in an Excel spreadsheet and tried to find a correlation between these data points. Try find the correlation with this data.

Excel Casino data

With Power BI and R, we can make this association all that much faster and with slicer for interactivity to drill into the data points. I first downloaded the R Correlation Plot custom visual located here and then Excel spreadsheet from above imported into Power BI. I was then able easily identify the correlations in a matter of minutes.

Positive correlations are identified with increasingly dark blue circles, negative correlation is red. The greater the bigger and darker the circle. Selecting “Nov” from the calendar slicer, you will notice that the intersection between “Low Temp” has a positive correlation (blue circle), so the lower the temperature the less you will realize in coin in for the that month.

Power BI and R Correlation Plot

Selecting the “Jul” from the calendar slicer, and notice that the correlation is different.

In this case, the correlation is zero between temperature and coin in.

Power BI and R Correlation Plot image 2

Conclusion

Hope this helps you quickly identify business insights in your organization.