its_poisson_wo_seas: ITS analysis for count outcomes with no seasonality...

View source: R/functions.R

its_poisson_wo_seasR Documentation

ITS analysis for count outcomes with no seasonality adjustment

Description

its_poisson_wo_seas fits a Poisson regression model to an ITS, and returns the model, the summary of the model (including the relative risk), and the original data together with the model predictions.

Usage

its_poisson_wo_seas(
  data,
  form,
  offset_name = NULL,
  time_name,
  intervention_start_ind,
  over_dispersion = FALSE,
  impact_model = "full",
  counterfactual = FALSE,
  print_summary = FALSE
)

Arguments

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

form

A formula with the response on the left, followed by the ~ operator, and the covariates on the right, separated by + operators. The formula should not contain an offest term.

offset_name

either a string indicating the name of the offset column in the data, or NULL. Default value is NULL

time_name

A string giving the name of the time variable. The time variable may or may not be supplied as a covariate in the formula

intervention_start_ind

Numeric - a number between 1 and nrow(data)-1 stating the time point of the start of the intervention

over_dispersion

Logical - indicating whether a quasi-Poisson model should be used to account for over dispersion (TRUE), or not (FLASE). Default value is FALSE.

impact_model

A string specifying the assumed impact model. Possible options include "full" corresponding to a model including both a level change and a slope change, "level" corresponding to a model including just a level change, and "slope" corresponding to a model including just a slope change. Default value is "full".

counterfactual

Logical - indicating whether the model-based counterfactual values should also be returned as an additional column in the data. Default value is FALSE, in which case the counterfactual values are not returned.

print_summary

Logical - indicating whethwe the entire model summary should be printed, or just the relevant effect size. Default value is FALSE in which case only the effect size, together with its 95% CI and P-value, are printed.

Value

The function returns a list with three elements: the fitted Poisson regression model, the summary of the model (including the relative risk), and the original data together with the model predictions.

Examples

data <- unemployed
form <- as.formula("unemployed ~ time")
intervention_start_ind <- which(data$year==2020 & data$month>2| data$year==2021)[1]
fit <- its_poisson_wo_seas(data=data,form=form,offset_name="labour", time_name = "time",intervention_start_ind=intervention_start_ind,over_dispersion=TRUE, impact_model = "full",counterfactual = TRUE)

Yael-Travis-Lumer/its2es documentation built on Oct. 31, 2022, 8:05 a.m.