its_zero_inflated_poisson | R Documentation |
its_zero_inflated_poisson
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.
its_zero_inflated_poisson( data, form, offset_name = NULL, time_name, intervention_start_ind, freq, seasonality = FALSE, impact_model = "full", counterfactual = FALSE, print_summary = FALSE )
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. |
seasonality |
Logical - indicating whether seasonal adjustment via Fourier terms should be used. Default value is FALSE, in which case seasonal adjustment is not considered. |
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. |
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.
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_poisson(data=data,form=form, time_name = "time",intervention_start_ind=intervention_start_ind, freq=12, seasonality=TRUE, impact_model = "full",counterfactual = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.