Pre-intervention, intervention and post-intervention period in impact plot

301 views
Skip to first unread message

Kathakali Seth

unread,
Jan 22, 2015, 2:01:35 AM1/22/15
to causal...@googlegroups.com, kathaka...@outlook.com
How to show pre-intervention, intervention and post-intervention period in impact plot (suppose in case of online campaign where number of clicks are measured)?

Kay Brodersen

unread,
Jan 22, 2015, 4:25:37 AM1/22/15
to Kathakali Seth, causal...@googlegroups.com, kathaka...@outlook.com
Hi Kathakali,

I'm not sure I understand your question. Can you provide more details and a reproducible example?

Many thanks,
Kay


On 22 January 2015 at 08:01, Kathakali Seth <kathaka...@gmail.com> wrote:
How to show pre-intervention, intervention and post-intervention period in impact plot (suppose in case of online campaign where number of clicks are measured)?

--
You received this message because you are subscribed to the Google Groups "CausalImpact" group.
To unsubscribe from this group and stop receiving emails from it, send an email to causalimpact...@googlegroups.com.
To post to this group, send email to causal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/causalimpact/610007d7-a6de-411d-b437-a846668c70a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kathakali Seth

unread,
Jan 22, 2015, 6:47:29 AM1/22/15
to causal...@googlegroups.com, kathaka...@gmail.com, kathaka...@outlook.com
Sorry for the inconvenience, Is there any way the impact plot can display 3 periods separated by dotted lines, the cumulative effect trend will be slower after campaign has ended.

Thanks
Kathakali

Kay Brodersen

unread,
Jan 26, 2015, 4:07:47 AM1/26/15
to Kathakali Seth, causal...@googlegroups.com, kathaka...@outlook.com
Hi Kathakali,

The plot() function in {CausalImpact} returns a ggplot2 object which you can modify using standard ggplot2 functions. For example:


plot(impact) +
  geom_vline(xintercept = 90, colour = "red",
             size = 0.8, linetype = "dashed")


Inline images 2


Kathakali Seth

unread,
Jan 27, 2015, 1:51:52 AM1/27/15
to causal...@googlegroups.com, kathaka...@gmail.com, kathaka...@outlook.com
Thank you Dr. Brodersen for answering my query.

I was wondering whether we could combine and show the effect of Campaign compared to pre campaign period and then again effect of ending the campaign against the campaign period. Please suggest.

Here is the simulated excel data file (in a crude way) from which csv file is created. Pre campaign period is "2011-1-1" to "2012-5-31, campaign period is "2012-6-1" to "2012-09-30" and "2012-10-1" to "2013-04-30" is again without campaign. I have created two plots

1.  Effect of campaign against pre campaign period
2. Effect of ending campaign against campaign period 

camp <- read.csv("Campaign_Simulated.csv",header=TRUE,sep=",")
data <- cbind(camp$Date,camp$Overall)
data <- as.data.frame(data)
names(data) <- c("Date","Click")
data$Date <- as.Date(data$Date)
data <- zoo(data$Click, data$Date)
pre.period <- as.Date(c("2011-1-1","2012-5-31"))
post.period <- as.Date(c("2012-6-1","2012-09-30"))
impact <- CausalImpact(data, pre.period, post.period, model.args=list(niter = 1e4),alpha=0.05)
plot(impact) + theme_bw(base_size = 9) 

pre.period <- as.Date(c("2012-6-1","2012-9-30"))
post.period <- as.Date(c("2012-10-1","2013-04-30"))
impact <- CausalImpact(data, pre.period, post.period, model.args=list(niter = 1e4),alpha=0.05)
plot(impact) + theme_bw(base_size = 9) 


Thank You
Kathakali 
Bayesian Structural Time Series with Simulated data.png
Campaign_Simulated.xlsx

Kay Brodersen

unread,
Feb 24, 2015, 4:55:09 AM2/24/15
to Kathakali Seth, causal...@googlegroups.com, kathaka...@outlook.com
Dear Kathakali,

Yes, that's exactly how I would approach the problem. Note that this may work best for campaigns that have a relatively uniform effect on the treatment metric over time. In the second analysis (where you use your campaign as the pre-period), pay particular attention to how well your model fits the data during the pre-period.

Best wishes,
Kay


Reply all
Reply to author
Forward
0 new messages