View source: R/visualisation.R
plot_counterfactual | R Documentation |
Smooths the predictions using a rolling mean, prepares the data for plotting, and generates the counterfactual plot for the application window. Data before the red box are reference window, red box is buffer and values after black, dotted line are effect window.
plot_counterfactual(
predictions,
params,
window_size = 14,
date_effect_start = NULL,
buffer = 0,
plot_pred_interval = TRUE
)
predictions |
The data.table containing the predictions (hourly) |
params |
Parameters for plotting, including the target variable. |
window_size |
The window size for the rolling mean (default is 14 days). |
date_effect_start |
A date. Start date of the effect that is to be evaluated. The data from this point onwards is disregarded for calculating model performance |
buffer |
Integer. An additional, optional buffer window before
|
plot_pred_interval |
Boolean. If |
The optional grey ribbon is a prediction interval for the hourly values. The
interpretation for a 90% prediction interval (to be defined in alpha
parameter
of run_counterfactual()
) is that 90% of the true hourly values
(not the rolled means) lie within the grey band. This might be helpful for
getting an idea of the variance of the data and predictions.
A ggplot object with the counterfactual plot. Can be adjusted further, e.g. set limits for the y-axis for better visualisation.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.