impact | R Documentation |
Function to create a table of the estimated model coefficients from a call to CausalArima
impact(
x,
format = "numeric",
horizon = NULL,
style = kable_styling,
digits = 3,
...
)
x |
Object of class |
format |
Required format for the table. Possible values in |
horizon |
Optional vector with elements of class Date. If provided, the function returns the estimated effects at the given time horizons. |
style |
Function to pass to |
digits |
Number of digits in table columns. |
... |
Optional arguments passed to other methods. |
A list with the following components:
impact_norm |
Estimated point, cumulative and temporal average effect assuming Normality of the error terms. |
impact_boot |
Estimated point, cumulative and temporal average effect by bootstrap. |
arima |
Arima order, coefficient estimates and accuracy measures for the estimated model in the pre-intervention period. |
## Example 1 (weekly data, no predictors)
# Generating a time series with weekly seasonality and a vector of dates
y <- simulate(Arima(ts(rnorm(100),freq=4), order=c(1,0,1), seasonal=c(1,0,1)),
nsim=800)
dates <- seq.Date(from = as.Date("2005-01-01"), by = "week", length.out = 800)
# Adding a fictional intervention
int.date <- as.Date("2019-05-11")
horizon <- as.Date(c("2019-12-07", "2020-02-15", "2020-04-25"))
y.new <- y ; y.new[dates >= int.date] <- y.new[dates >= int.date]*1.40
# Causal effect estimation
ce <- CausalArima(y = ts(y.new, frequency = 4), dates = dates, int.date = int.date)
# Table of the estimated effects (numeric and latex)
impact(ce)
impact(ce, horizon = horizon)
tab_latex <- impact(ce, format = "latex", horizon = horizon, digits = 3, latex_options = "striped")
tab_latex$impact_norm$average
## Example 2 (daily data, with predictors)
# Loading data and setting dates
data(sales)
y <- sales[, "Sales"]
dates <- as.Date(sales[, "Dates"])
int.date <- as.Date("2018-10-04")
horizon<- as.Date(c("2018-11-04","2019-01-04","2019-04-30"))
xreg <- sales[, 4:12]
# Causal effect estimation
ce <- CausalArima(y = ts(y, frequency = 7), xreg = xreg, int.date = int.date,
dates = dates, nboot = 100)
# Table of the estimated effects (html)
tab_html <- impact(ce, format = "html", horizon = horizon)
tab_html$arima$param
tab_html <- impact(ce, format = "html", horizon = horizon, style = kable_classic,
html_font = "Cambria")
tab_html$arima$param
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.