Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowTry your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now
Your file has been submitted successfully. We’re processing it now - please check back in a few minutes to view your report.
09-01-2017 02:54 AM
Marketing Optimization using Linear Programming
CMOs need to make complex decisions about budget allocation and marketing investment. Deciding which campaigns will receive funding is never easy, especially with multiple factors and obligations that need to be taken into account.
This dashboard helps marketing managers to optimize the 'Return on Marketing Investment' (ROMI) across four channels. TV Ads, SEO , Adwords and Facebook. Based on the set parameters and rules , the dashboard gives a R Linear Programming Solutions that optimizes the ROMI.
R Libraries used: linprog - for linear programming, grid, gridExtra,gtable - for plotting the results as a table
eyJrIjoiZTNlZjNkMTktMWY3Ni00ZTRlLTg0MmEtMzYxMWQ2OTI4MzIyIiwidCI6IjViNjdjODg2LTFhMjYtNDk4OC1hNzY3LTEwOTQzZTRkMTA2YyIsImMiOjEwfQ
R Code:
my_df <- `dataset`
library(linprog)
ROI <- c(my_df$`TVROI Value`/100,my_df$`SEOROI Value`/100,my_df$`ADWORDSROI Value`/100,my_df$`FacebookROI Value`/100)
bVect <- c(my_df$`Total Budget`, 0, 0, -200000, -80000, -60000, 220000, 0, my_df$`Customer Base`)
AMatrix <- rbind(
c(1,1,1,1), # TOTAL
c(0.6,-0.4,-0.4,0.6), # SEO + AdWords > 60%
c(-0.2,-0.2,-0.2,0.8), # FB < 20%
c(-1,0,0,0), # Min TV
c(0,0,0,-1), # Min FB
c(0,-1,0,0), # Min SEO
c(0,1,0,0), # Max SEO
c(0,-3,1,0), # Adwords <= 3 SEO
c(my_df$`TV Reach Value`,my_df$`SEO Reach Value`,my_df$`Adwords Reach Value`,my_df$`Facebook Reach Value`) # Campaign reach
)
lpsol <- solveLP(ROI, bVect, AMatrix, TRUE)
OptROI <- paste0("$", formatC(as.numeric(lpsol$opt), format="f", digits=0, big.mark=","))
TVSpend <- paste0("$", formatC(as.numeric(lpsol$solution[1]), format="f", digits=0, big.mark=","))
SEOSpend <- paste0("$", formatC(as.numeric(lpsol$solution[2]), format="f", digits=0, big.mark=","))
AdwordsSpend <- paste0("$", formatC(as.numeric(lpsol$solution[3]), format="f", digits=0, big.mark=","))
FacebookSpend <- paste0("$", formatC(as.numeric(lpsol$solution[4]), format="f", digits=0, big.mark=","))
plot_df <- data.frame(Description=c('Optimum ROI','TV Spend','SEO Spend','Adwords Spend','Facebook Spend'),
Value=c(OptROI,TVSpend,SEOSpend,AdwordsSpend,FacebookSpend))
library(gtable)
library(gridExtra)
library(grid)
tt <- ttheme_minimal(
core=list(bg_params = list(fill = blues9[1:5], col=NA),
fg_params=list(fontface=1,fontsize=20)),
colhead=list(fg_params=list(col="navyblue", fontface=1,fontsize=20)))
g <- tableGrob(plot_df[1:5,], rows = NULL,theme=tt)
g <- gtable_add_grob(g,
grobs = rectGrob(gp = gpar(fill = NA, lwd = 2)),
t = 2, b = nrow(g), l = 1, r = ncol(g))
g <- gtable_add_grob(g,
grobs = rectGrob(gp = gpar(fill = NA, lwd = 2)),
t = 1, l = 1, r = ncol(g))
grid.newpage()
grid.draw(g)