2021-04-08 00:05:37 +03:00
|
|
|
% Generated by roxygen2: do not edit by hand
|
|
|
|
% Please edit documentation in R/create_ITSA.R
|
|
|
|
\name{create_ITSA}
|
|
|
|
\alias{create_ITSA}
|
2022-05-27 13:13:41 +03:00
|
|
|
\title{Estimate an effect of intervention on every Viva Insights metric in input
|
|
|
|
file by applying single-group Interrupted Time-Series Analysis (ITSA)}
|
2021-04-08 00:05:37 +03:00
|
|
|
\usage{
|
|
|
|
create_ITSA(
|
|
|
|
data,
|
|
|
|
before_start = min(as.Date(data$Date, "\%m/\%d/\%Y")),
|
|
|
|
before_end,
|
|
|
|
after_start,
|
|
|
|
after_end = max(as.Date(data$Date, "\%m/\%d/\%Y")),
|
|
|
|
ac_lags_max = 7,
|
|
|
|
return = "table"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
\arguments{
|
2021-05-17 15:59:09 +03:00
|
|
|
\item{data}{Person Query as a dataframe including date column named \code{Date}.
|
2021-08-27 16:51:59 +03:00
|
|
|
This function assumes the data format is MM/DD/YYYY as is standard in a
|
2021-11-15 18:16:39 +03:00
|
|
|
Viva Insights query output.}
|
2021-04-08 00:05:37 +03:00
|
|
|
|
2021-05-17 15:59:09 +03:00
|
|
|
\item{before_start}{Start date of 'before' time period in MM/DD/YYYY format
|
|
|
|
as character type. Before time period is the period before the intervention
|
|
|
|
(e.g. training program, re-org, shift to remote work) occurs and bounded by
|
|
|
|
before_start and before_end parameters. Longer period increases likelihood
|
|
|
|
of achieving more statistically significant results. Defaults to earliest
|
|
|
|
date in dataset.}
|
2021-04-08 00:05:37 +03:00
|
|
|
|
2021-05-17 15:59:09 +03:00
|
|
|
\item{before_end}{End date of 'before' time period in MM/DD/YYYY format as
|
|
|
|
character type.}
|
2021-04-08 00:05:37 +03:00
|
|
|
|
2021-05-17 15:59:09 +03:00
|
|
|
\item{after_start}{Start date of 'after' time period in MM/DD/YYYY format as
|
|
|
|
character type. After time period is the period after the intervention
|
|
|
|
occurs and bounded by after_start and after_end parameters. Longer period
|
|
|
|
increases likelihood of achieving more statistically significant results.
|
|
|
|
Defaults to date after before_end.}
|
2021-04-08 00:05:37 +03:00
|
|
|
|
2021-05-17 15:59:09 +03:00
|
|
|
\item{after_end}{End date of 'after' time period in MM/DD/YYYY format as
|
|
|
|
character type. Defaults to latest date in dataset.}
|
2021-04-08 00:05:37 +03:00
|
|
|
|
|
|
|
\item{ac_lags_max}{maximum lag for autocorrelation test. Default is 7}
|
|
|
|
|
2021-05-17 15:59:09 +03:00
|
|
|
\item{return}{String specifying what output to return. Defaults to "table".
|
2021-04-08 00:05:37 +03:00
|
|
|
Valid return options include:
|
|
|
|
\itemize{
|
|
|
|
\item \code{'plot'}: return a list of plots.
|
2021-05-17 15:59:09 +03:00
|
|
|
\item \code{'table'}: return data.frame with estimated models' coefficients and
|
|
|
|
their corresponding p-values You should look for significant p-values in
|
|
|
|
beta_2 to indicate an immediate treatment effect, and/or in beta_3 to
|
|
|
|
indicate a treatment effect over time
|
2021-04-08 00:05:37 +03:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
\description{
|
2021-05-17 15:59:09 +03:00
|
|
|
r lifecycle::badge('experimental')
|
|
|
|
|
2021-04-08 00:05:37 +03:00
|
|
|
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
|
2021-06-08 20:06:51 +03:00
|
|
|
|
|
|
|
This function further requires the installation of 'sandwich', 'portes', and
|
|
|
|
'lmtest' in order to work. These packages can be installed from CRAN using
|
|
|
|
\code{install.packages()}.
|
2021-04-08 00:05:37 +03:00
|
|
|
}
|
2021-05-17 15:59:09 +03:00
|
|
|
\details{
|
2022-05-27 12:46:31 +03:00
|
|
|
This function uses the additional package dependencies 'sandwich' and
|
|
|
|
'lmtest'. Please install these separately from CRAN prior to running the
|
2021-05-17 15:59:09 +03:00
|
|
|
function.
|
2022-05-26 18:10:53 +03:00
|
|
|
|
2022-05-27 12:46:31 +03:00
|
|
|
As of May 2022, the 'portes' package was archived from CRAN. The dependency
|
|
|
|
has since been removed and dependent functions \code{Ljungbox()} incorporated into
|
|
|
|
the \strong{wpa} package.
|
2021-05-17 15:59:09 +03:00
|
|
|
}
|
2022-05-27 12:46:31 +03:00
|
|
|
\examples{
|
|
|
|
# Returns summary table
|
2021-04-08 00:05:37 +03:00
|
|
|
|
|
|
|
create_ITSA(
|
|
|
|
data = sq_data,
|
2023-08-17 17:45:55 +03:00
|
|
|
before_start = "12/15/2019",
|
|
|
|
before_end = "12/29/2019",
|
|
|
|
after_start = "1/5/2020",
|
2021-04-08 00:05:37 +03:00
|
|
|
after_end = "1/26/2020",
|
|
|
|
ac_lags_max = 7,
|
|
|
|
return = "table")
|
|
|
|
|
|
|
|
# Returns list of plots
|
|
|
|
|
|
|
|
plot_list <-
|
|
|
|
create_ITSA(
|
|
|
|
data = sq_data,
|
2023-08-17 17:45:55 +03:00
|
|
|
before_start = "12/15/2019",
|
|
|
|
before_end = "12/29/2019",
|
|
|
|
after_start = "1/5/2020",
|
2021-04-08 00:05:37 +03:00
|
|
|
after_end = "1/26/2020",
|
|
|
|
ac_lags_max = 7,
|
|
|
|
return = 'plot')
|
|
|
|
|
|
|
|
# Extract a plot as an example
|
|
|
|
plot_list$Workweek_span
|
2022-05-26 18:10:53 +03:00
|
|
|
|
2022-05-27 12:46:31 +03:00
|
|
|
}
|
2021-04-08 00:05:37 +03:00
|
|
|
\seealso{
|
|
|
|
Other Flexible Input:
|
|
|
|
\code{\link{period_change}()}
|
|
|
|
}
|
2021-05-17 15:59:09 +03:00
|
|
|
\author{
|
|
|
|
Aleksey Ashikhmin \href{mailto:alashi@microsoft.com}{alashi@microsoft.com}
|
|
|
|
}
|
2021-04-08 00:05:37 +03:00
|
|
|
\concept{Flexible Input}
|
|
|
|
\concept{Interrupted Time-Series Analysis}
|