google / CausalImpact

An R package for causal inference in time series
Apache License 2.0
1.71k stars 254 forks source link

Error with plot(impact): confidence bands won't plot #38

Closed johnf1004 closed 4 years ago

johnf1004 commented 4 years ago

I'm having an issue where plot() is just returning bare line plots with no error bands. After running into this problem with my own data I tried to copy the code from the CI tutorial exactly and I get the same problem:


library(CausalImpact)

set.seed(1)
x1 <- 100 + arima.sim(model = list(ar = 0.999), n = 100)
y <- 1.2 * x1 + rnorm(100)
y[71:100] <- y[71:100] + 10
data <- cbind(y, x1)

matplot(data, type = "l")

pre.period <- c(1, 70)
post.period <- c(71, 100)

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

plot(impact)

image

What is it about my session that could be causing this? SessionInfo() posted below:

R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_3.2.1       CausalImpact_1.2.3  bsts_0.9.2          xts_0.11-2         
[5] zoo_1.8-6           BoomSpikeSlab_1.2.1 Boom_0.9.3          MASS_7.3-51.1      

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3       igraph_1.2.4.2   magrittr_1.5     tidyselect_0.2.5 munsell_0.5.0   
 [6] colorspace_1.4-1 lattice_0.20-38  R6_2.4.1         rlang_0.4.2      stringr_1.4.0   
[11] plyr_1.8.5       dplyr_0.8.3      tools_3.5.2      grid_3.5.2       gtable_0.3.0    
[16] withr_2.1.2      lazyeval_0.2.2   assertthat_0.2.1 tibble_2.1.3     lifecycle_0.1.0 
[21] crayon_1.3.4     farver_2.0.1     reshape2_1.4.3   purrr_0.3.3      glue_1.3.1      
[26] labeling_0.3     stringi_1.4.3    compiler_3.5.2   pillar_1.4.3     scales_1.1.0    
[31] pkgconfig_2.0.3 
alhauser commented 4 years ago

This is a duplicate of issue #36.

It is already fixed in the latest CausalImpact version (1.2.4) available on Github, and it should become available on CRAN in the next days (submitted yesterday).