its_lm_fourier | R Documentation |
its_lm_fourier
fits a linear regression model asjusted to seasonality, and returns the model, the summary of the model (including the mean difference and Cohen's d), and the original data together with the model predictions.
its_lm_fourier( data, form, time_name, intervention_start_ind, freq, keep_significant_fourier = TRUE, 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. |
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. |
keep_significant_fourier |
Logical - indicating whether only the significant Fourier terms should be considered. Default is TRUE and then the model is fitted twice; once to obtain the significant Fourier terms, and second time keeping only the significant Fourier terms. If FALSE, then all the Fourier terms are used. |
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 linear regression model, the summary of the model (including the mean difference and Cohen's d), and the original data together with the model predictions.
data <- unemployed form <- as.formula("percent ~ time") intervention_start_ind <- which(data$year==2020 & data$month>2| data$year==2021)[1] fit <- its_lm_fourier(data=data,form=form,time_name = "time",intervention_start_ind=intervention_start_ind,freq=12, keep_significant_fourier=TRUE, impact_model = "full",counterfactual = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.