This package implements interrupted time series analysis for both continuous and count outcomes, and quantifies the associated effect size, as described in Effect size quantification for interrupted time series analysis: Implementation in R and analysis for Covid-19 research. The main functions fit an ITS regression model, and then use the fitted values and the model-based counterfactual values to quantify the effect size (Cohen's d for continuous outcomes and relative risk for count outcomes). An example describing how to install and use this package is described below. A more detailed tutorial, including the data analysis described in the paper, is also available with this package (Rmd + pdf file).
You can install the package from its GitHub repository. You first need to install the devtools package.
install.packages("devtools",repos = "http://cran.us.r-project.org")
Then install its2es using the install_github
function in the devtools package.
library(devtools) install_github("Yael-Travis-Lumer/its2es")
library(its2es) data <- Israel_mortality
form <- as.formula("percent ~ time") intervention_start_ind <- which(data$Year==2020 & data$Month==3)
fit <- its_lm(data=data,form=form,time_name = "time",intervention_start_ind=intervention_start_ind, freq=12,seasonality= "full", impact_model = "full",counterfactual = TRUE, print_summary = FALSE)
p <- plot_its_lm(data=fit$data,intervention_start_ind=intervention_start_ind, y_lab="All-cause mortality percent", response="percent", date_name= "Date") p
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.