knitr::opts_chunk$set(echo = TRUE)

\thispagestyle{fancy}

library(xts)
library(magrittr)
library(huxtable)
library(flextable)
library(tscausal)
library(rmarkdown)
x <- readRDS(paste0(params$dir,"/causal_tmp.rds"))
idate <- x$intervention_date
horizon <- NROW(x$post_actual)

Model Report{-}

xx <- tscausal:::.table.print.tscausal(x, digits = 4)
tab <- as_hux(xx, add_colnames = TRUE) %>% add_rownames(colname = "Statistic", TRUE) %>% theme_grey() %>% map_align(by_cols("left","right","right")) %>% huxtable::set_caption("Causal Analysis") %>% huxtable::set_caption_pos("bottom") %>% huxtable::set_position("left")
tab$Statistic[1] <- "Statistic"
tab
p <- x$summary$p[1]
cat("Forecast Distribution tail-area probability p:   ", round(p, 5), "  \n")
cat("Forecast Distribution prob. of a causal effect:  ", round((1 - p) * 100, ifelse(p < 0.01, 5, ifelse(p < 0.05, 3, 0))), "\\%  \n")
plot(x)


tsmodels/tscausal documentation built on Dec. 31, 2020, 9:38 a.m.