create_itsa | R Documentation |
r lifecycle::badge('experimental')
This function implements ITSA method described in the paper 'Conducting interrupted time-series analysis for single- and multiple-group comparisons', Ariel Linden, The Stata Journal (2015), 15, Number 2, pp. 480-500
This function further requires the installation of 'sandwich' and 'lmtest' in
order to work. These packages can be installed from CRAN using
install.packages()
.
create_itsa(
data,
metrics = NULL,
before_start = NULL,
before_end = NULL,
after_start = NULL,
after_end = NULL,
ac_lags_max = 7,
return = "table"
)
data |
Person Query as a dataframe including date column named
|
metrics |
A character vector containing the variable names to perform the interrupted time series analysis for. |
before_start |
String specifying the start date of the 'before'
time period in |
before_end |
String specifying the end date of 'before' time
period in |
after_start |
String specifying the start date of the 'after'
time period in |
after_end |
String specifying the end date of the 'after' time
period in |
ac_lags_max |
Numeric value specifying the maximum lag for the autocorrelation test. The Ljung-Box test is used to check for autocorrelation in the model residuals up to this specified number of lags. Higher values check for longer-term dependencies in the time series data. |
return |
String specifying what output to return. Defaults to "table". Valid return options include:
|
This function uses the additional package dependencies 'sandwich' and 'lmtest'. Please install these separately from CRAN prior to running the function.
As of May 2022, the 'portes' package was archived from CRAN. The dependency
has since been removed and dependent functions Ljungbox()
incorporated into
the wpa package.
When 'data' is passed to return
, a data frame with the following columns:
metric_name
: Name of the metric being analyzed.
beta_2
: Coefficient for the immediate treatment effect.
beta_3
: Coefficient for the treatment effect over time.
beta_2_pvalue
: P-value for the immediate treatment effect.
beta_3_pvalue
: P-value for the treatment effect over time.
AR_flag
: Logical flag indicating whether autocorrelation was detected.
error_warning
: Error or warning message if applicable.
Aleksey Ashikhmin alashi@microsoft.com
## Not run:
# Returns summary table
create_itsa(
data = pq_data,
metrics = c("Collaboration_span", "Internal_network_size"),
before_end = "2024-07-01",
after_start = "2024-07-01",
ac_lags_max = 7,
return = "table"
)
# Returns list of plots
plot_list <-
create_itsa(
data = pq_data,
metrics = c("Collaboration_span", "Internal_network_size"),
before_end = "2024-07-01",
after_start = "2024-07-01",
ac_lags_max = 7,
return = "plot"
)
# Extract a plot as an example
plot_list$Collaboration_span
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.