its_zero_inflated_fourier: ITS analysis for zero inflated count outcomes with seasonal...

View source: R/functions.R

its_zero_inflated_fourierR Documentation

ITS analysis for zero inflated count outcomes with seasonal adjustment

Description

its_zero_inflated_fourier fits a zero-inflated 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_zero_inflated_fourier(
  data,
  form,
  offset_name = NULL,
  time_name,
  intervention_start_ind,
  freq,
  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

freq

A positive integer describing the frequency of the time series.

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 <- zero_inflated_sim_data
form <- as.formula("monthly_total ~ time")
intervention_start_ind <- which(data$Year==2020 & data$Month==3)
fit <- its_zero_inflated_fourier(data=data,form=form, time_name = "time",intervention_start_ind=intervention_start_ind, freq=12, impact_model = "full",counterfactual = TRUE)

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