print.cArima | R Documentation |
Quick shortcut to see the results of a call to CausalArima
, i.e., the estimated
causal effects at each time point provided in horizon
. If horizon = NULL
(default), the function prints the estimated effects at the last date of the
post-intervention period.
## S3 method for class 'cArima'
print(x, type = "norm", horizon = NULL)
x |
Object of class |
type |
Character string indicating the summary to be produced. Possible values
in |
horizon |
Optional vector with elements of class |
An extract from the data.frame returned by cArima$norm$inf
or cArima$boot$inf
corresponding to the dates provided in horizon (if horizon = NULL
,
a single row corresponding to the last date of the post-intervention period) with the
following columns:
tau |
The estimated causal effect at the given time horizon or at the end of analysis
period if |
pvalue.tau |
Left-sided ( |
sum.tau |
The estimated cumulative causal effect up to the given time horizon or at the end of analysis
period if |
pvalue.sum |
Left-sided ( |
avg.tau |
The estimated temporal average causal effect up to the given time horizon or at the end of analysis
period if |
pvalue.avg |
Left-sided ( |
Additional columns are provided with the estimated standard deviations for the point, cumulative and temporal average effects.
## Example 1 (daily data, no predictors)
# Generating a time series of length 1000 and a vector of dates
y <- 0.5*seq(0.5, 250, by = 0.5) + rnorm(500, sd = 6)
dates <- seq.Date(from = as.Date("2014-01-05"), by = "days", length.out = 500)
# Adding a fictional intervention
int.date <- as.Date("2015-04-01")
horizon <- as.Date(c("2015-04-10", "2015-04-20"))
y.new <- y ; y.new[dates >= int.date] <- y.new[dates >= int.date]*1.25
# Causal effect estimation
ce <- CausalArima(y = y.new, auto = TRUE, ic = "aic",
dates = dates, int.date = int.date, nboot = 1000)
# Print
print(ce, type = "norm")
print(ce, type = "boot", horizon = horizon)
## 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[, "Price"]
# Causal effect estimation
ce <- CausalArima(y = ts(y, frequency = 7), xreg = xreg, int.date = int.date,
dates = dates, nboot = 100)
# Print
print(ce, horizon = horizon)
print(ce, type = "boot", horizon = horizon)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.