plot_its_lm | R Documentation |
plot_its_lm
uses ggplot2 to plot the model-based fitted values, together with a scatterplot of the observed time series
plot_its_lm(data, intervention_start_ind, y_lab, response, date_name)
data |
The data frame corresponding to the supplied formula, existing of at least 2 variables: (1) the count outcome, and (2) a vector of time points |
intervention_start_ind |
Numeric - a number between 1 and nrow(data)-1 stating the time point of the start of the intervention |
y_lab |
a string with the y axis label for the predictions |
response |
The name of the response variable to be plotted in the scatterplot |
date_name |
A string giving the name of the date column. The date column must be a Date object. |
a ggplot object including a scatterplot of the time series, the predictions line, and the counterfactual predictions in red (if available.
data <- unemployed form <- as.formula("percent ~ time") intervention_start_ind <- which(data$year==2020 & data$month>2| data$year==2021)[1] fit <- its_lm(data=data,form=form, time_name = "time",intervention_start_ind=intervention_start_ind, freq=12, seasonality= "none", impact_model = "full",counterfactual = TRUE) new_data <- fit$data y_lab <- "Unemployment percent" response <- "percent" p <- plot_its_lm(new_data,intervention_start_ind,y_lab,response, "dt")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.