refactor: remove extra dependencies

'sandwich', 'lmtest', 'portes'
This commit is contained in:
Martin Chan 2021-05-17 13:59:09 +01:00
Родитель 3bf86107d7
Коммит 67f29a6614
3 изменённых файлов: 73 добавлений и 37 удалений

Просмотреть файл

@ -12,6 +12,7 @@ Authors@R: c(
person(given = "Lucas", family = "Hogner", role = "ctb", email = "lucas.hogner@microsoft.com"),
person(given = "Jasminder", family = "Thind", role = "ctb", email = "jasminder.thind@microsoft.com"),
person(given = "Simone", family = "Liebal", role = "ctb", email = "simone.liebal@microsoft.com"),
person(given = "Aleksey", family = "Ashikhmin", role = "ctb", email = "alashi@microsoft.com"),
person(given = "Ellen", family = "Trinklein", role = "ctb"),
person(given = "Microsoft Corporation", role = "cph")
)
@ -54,10 +55,7 @@ Imports:
proxy,
ggwordcloud,
methods,
data.table,
lmtest,
portes,
sandwich
data.table
RoxygenNote: 7.1.1
Roxygen: list(markdown = TRUE)
VignetteBuilder: knitr
@ -67,5 +65,8 @@ Suggests:
leiden,
lifecycle,
fst,
glue
glue,
lmtest,
portes,
sandwich
Language: en-US

Просмотреть файл

@ -6,7 +6,7 @@
#' @title
#' Estimate an effect of intervention on every WPA metric in input file by
#' applying single-group Interrupted Time-Series Analysis (ITSA)
#'
#'
#' @author Aleksey Ashikhmin <alashi@@microsoft.com>
#'
#' @description
@ -16,25 +16,37 @@
#' interrupted time-series analysis for single- and multiple-group comparisons',
#' Ariel Linden, The Stata Journal (2015), 15, Number 2, pp. 480-500
#'
#' @param data Person Query as a dataframe including date column named 'Date'
#' This function assumes the data format is MM/DD/YYYY as is standard in a WpA query output.
#' @param 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.
#' @param before_end End date of 'before' time period in MM/DD/YYYY format as character type.
#' @param 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.
#' @param after_end End date of 'after' time period in MM/DD/YYYY format as character type. Defaults to latest date in dataset.
#' @details
#' This function uses the additional package dependencies 'sandwich', 'lmtest',
#' and 'portes'. Please install these separately from CRAN prior to running the
#' function.
#'
#' @param data Person Query as a dataframe including date column named `Date`.
#' This function assumes the data format is MM/DD/YYYY as is standard in a WpA
#' query output.
#' @param 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.
#' @param before_end End date of 'before' time period in MM/DD/YYYY format as
#' character type.
#' @param 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.
#' @param after_end End date of 'after' time period in MM/DD/YYYY format as
#' character type. Defaults to latest date in dataset.
#' @param ac_lags_max maximum lag for autocorrelation test. Default is 7
#' @param return String specifying what output to return. Defaults to "table".
#' Valid return options include:
#' - 'plot': return a list of plots.
#' - '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
#' - `'plot'`: return a list of plots.
#' - `'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
#'
#' @import dplyr
#' @import ggplot2
@ -47,7 +59,7 @@
#'
#'
#' @examples
#'
#' \donttest{
#' # Returns summary table
#'
#' create_ITSA(
@ -73,7 +85,7 @@
#'
#' # Extract a plot as an example
#' plot_list$Workweek_span
#'
#' }
#' @export
create_ITSA <-
@ -319,7 +331,7 @@ create_ITSA <-
# the main title
p_final <- p_final + theme(
plot.title = element_text(color="blue", size=14, face="bold.italic"))
# Save plot in list
results_plot[[metric_name]] <- p_final
}else{

Просмотреть файл

@ -16,35 +16,55 @@ create_ITSA(
)
}
\arguments{
\item{data}{Person Query as a dataframe including date column named 'Date'
This function assumes the data format is MM/DD/YYYY as is standard in a WpA query output.}
\item{data}{Person Query as a dataframe including date column named \code{Date}.
This function assumes the data format is MM/DD/YYYY as is standard in a WpA
query output.}
\item{before_start}{Start date of 'before' time period in YYYY-MM-DD format as character type. Defaults to earliest date in dataset.}
\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.}
\item{before_end}{End date of 'before' time period in YYYY-MM-DD format as character type.}
\item{before_end}{End date of 'before' time period in MM/DD/YYYY format as
character type.}
\item{after_start}{Start date of 'after' time period in YYYY-MM-DD format as character type. Defaults to day after before_end.}
\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.}
\item{after_end}{End date of 'after' time period in YYYY-MM-DD format as character type. Defaults to latest date in dataset.}
\item{after_end}{End date of 'after' time period in MM/DD/YYYY format as
character type. Defaults to latest date in dataset.}
\item{ac_lags_max}{maximum lag for autocorrelation test. Default is 7}
\item{return}{String specifying what output to return. Defaults to \code{"table"}.
\item{return}{String specifying what output to return. Defaults to "table".
Valid return options include:
\itemize{
\item \code{'plot'}: return a list of plots.
\item \code{'table'}: return data.frame with estimated models' coefficients and their corresponding p-values
You should look for significant p-values in \code{beta_2} to indicate an immediate treatment effect,
and/or in \code{beta_3} to indicate a treatment effect over time
\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
}}
}
\description{
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
}
\details{
This function uses the additional package dependencies 'sandwich', 'lmtest',
and 'portes'. Please install these separately from CRAN prior to running the
function.
}
\examples{
\donttest{
# Returns summary table
create_ITSA(
@ -70,11 +90,14 @@ plot_list <-
# Extract a plot as an example
plot_list$Workweek_span
}
}
\seealso{
Other Flexible Input:
\code{\link{period_change}()}
}
\author{
Aleksey Ashikhmin \href{mailto:alashi@microsoft.com}{alashi@microsoft.com}
}
\concept{Flexible Input}
\concept{Interrupted Time-Series Analysis}