I need to run causal impact on every 5-dma combo to determine which 5-dmas constitute the best control group for the remaining 204 dmas (test group). The data provided is for all of 2019 and will determine the control/test group for a 2020 marketing campaign. I've included the R code I've been working with which allows me to choose one DMA and the best five DMAs for a control group.
##---------------------------------------------------
## R Code Below
##---------------------------------------------------
install.packages('devtools') library(devtools) install.packages('dtw') install_github('google/CausalImpact') install_github('klarsen1/MarketMatching', build_vignettes=TRUE) install.packages('knitr') library(knitr) library(MarketMatching) mydata = read.csv(file = 'radio_date_dma_kpi_20200106.csv', header=TRUE) mydata$date <- as.Date(mydata$date) mydata$dma <- as.character(mydata$dma) mydata$kpi <- as.numeric(mydata$kpi) mm <- best_matches(data=mydata, id_variable='dma', date_variable='date', matching_variable='kpi', parallel=FALSE, markets_to_be_matched= 'ATLANTA', ### can we introduce a function here to run through every combination of 204 dmas? warping_limit=1, # warping limit=1 dtw_emphasis=1, # rely only on dtw for pre-screening matches=5)
About the recuiterMember since May 20, 2018 Puneet K.
from Calarasi, Romania