0
$\begingroup$

This might be a very basic code question, but thank you for your help. I have used the Causal Impact package to run a regression on a data set with 144 monthly observations, cutting at point 88. I want to be able to see all the predicted data points, both pre and post intervention (i.e. the data for the dotted blue line in the plot), but I am not sure of the code in R to display this.

The code for the model so far is:

library(CausalImpact)
setwd("C:/Users/...")
mydata <- read.csv(file="revisionx.csv", header=TRUE, sep=",")
pre.period <- c(1, 87)
post.period <- c(88, 144)
model.args = list(nseasons = 48, season.duration = 3)
impact <- CausalImpact(mydata, pre.period, post.period)
plot(impact)
summary(impact)
$\endgroup$
0
$\begingroup$

The CausalImpact object returns a list with four objects.

These are:

  • series
  • summary
  • report
  • model

You can find out more in the documentation ?CausalImpact in the console.

I think what you want is the first one here:

impact[[1]] # series
impact[[2]] # summary
impact[[3]] # report
impact[[4]] # model
$\endgroup$
  • 1
    $\begingroup$ That's exactly what I needed. Thank you. $\endgroup$ – holandgents506 Sep 1 at 1:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.