How to label x axis with the dates?

104 views
Skip to first unread message

inj...@gmail.com

unread,
Jan 5, 2015, 5:41:02 AM1/5/15
to causal...@googlegroups.com
Hi!

> How to label x axis with the dates?
I've tried to customize plot() parameters but this is full stuck of errors, that can be imagined (((
Please help!

Kay Brodersen

unread,
Jan 8, 2015, 6:33:37 AM1/8/15
to inj...@gmail.com, causal...@googlegroups.com
Hi injamed@,

The plot() function adds an appropriate x-axis automatically if your input data is a time series.

Based on the example in the documentation, simply replace:

  data <- cbind(y, x1)
  pre.period <- c(1, 70)
  post.period <- c(71, 100)

by something like:

  time.points <- seq.Date(as.Date("2014-01-01"), by = 1, length.out = 100)
  data <- zoo(cbind(y, x1), time.points)
  pre.period <- time.points[c(1, 70)]
  post.period <- time.points[c(71, 100)]

to obtain:

  impact <- CausalImpact(data, pre.period, post.period)
  plot(impact)

Inline images 1

Kay



--
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/1087cb00-90de-433f-9f38-a78883edf541%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kay Brodersen

unread,
Jan 8, 2015, 11:19:09 AM1/8/15
to inj...@gmail.com, causal...@googlegroups.com
As a follow-up, the package documentation now also contains this example.

Reply all
Reply to author
Forward
0 new messages