Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow additional arguments to be passed to stats::stl() #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Imports:
cli,
crayon,
rstudioapi
RoxygenNote: 6.1.1
RoxygenNote: 7.1.0
Roxygen: list(markdown = TRUE)
Suggests:
tidyverse,
Expand Down
10 changes: 6 additions & 4 deletions R/time_decompose_methods.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#' Methods that power time_decompose()
#'
#' @inheritParams time_decompose
#' @param robust logical indicating if robust fitting be used in the loess procedure of the underlying function call to [stats::stl()].
#' @param ... Additional parameters passed to the underlying function call to [stats::stl()].
#'
#' @return A `tbl_time` object containing the time series decomposition.
#'
Expand All @@ -25,7 +27,7 @@

#' @export
#' @rdname decompose_methods
decompose_twitter <- function(data, target, frequency = "auto", trend = "auto", message = TRUE) {
decompose_twitter <- function(data, target, frequency = "auto", trend = "auto", message = TRUE, robust = TRUE, ...) {

# Checks
if (missing(target)) stop('Error in decompose_twitter(): argument "target" is missing, with no default', call. = FALSE)
Expand All @@ -47,7 +49,7 @@ decompose_twitter <- function(data, target, frequency = "auto", trend = "auto",
decomp_tbl <- data %>%
dplyr::pull(!! target_expr) %>%
stats::ts(frequency = freq) %>%
stats::stl(s.window = "periodic", robust = TRUE) %>%
stats::stl(s.window = "periodic", robust = robust, ...) %>%
sweep::sw_tidy_decomp() %>%
dplyr::select(-c(index, seasadj)) %>%
# forecast::mstl() %>%
Expand Down Expand Up @@ -141,7 +143,7 @@ decompose_twitter <- function(data, target, frequency = "auto", trend = "auto",

#' @export
#' @rdname decompose_methods
decompose_stl <- function(data, target, frequency = "auto", trend = "auto", message = TRUE) {
decompose_stl <- function(data, target, frequency = "auto", trend = "auto", message = TRUE, robust = TRUE, ...) {

# Checks
if (missing(target)) stop('Error in decompose_stl(): argument "target" is missing, with no default', call. = FALSE)
Expand All @@ -162,7 +164,7 @@ decompose_stl <- function(data, target, frequency = "auto", trend = "auto", mess
decomp_tbl <- data %>%
dplyr::pull(!! target_expr) %>%
stats::ts(frequency = freq) %>%
stats::stl(s.window = "periodic", t.window = trnd, robust = TRUE) %>%
stats::stl(s.window = "periodic", t.window = trnd, robust = robust, ...) %>%
sweep::sw_tidy_decomp() %>%
# forecast::mstl() %>%
# as.tibble() %>%
Expand Down
16 changes: 11 additions & 5 deletions man/anomalize.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/anomalize_methods.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions man/anomalize_package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 23 additions & 5 deletions man/decompose_methods.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions man/plot_anomalies.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions man/plot_anomaly_decomposition.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/tidyverse_cran_downloads.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions man/time_apply.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions man/time_decompose.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/time_frequency.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.