Skip to content

Commit

Permalink
Improve classical decomposition's season_adjust aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelloharawild committed Nov 11, 2023
1 parent 1ad4cfd commit 2823121
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# feasts (development version)

## Bug fixes

* Changed the metadata of classical decomposition's components to better reflect
the seasonally adjusted variable's structure.

# feasts 0.3.1

Minor patch to resolve CRAN check issues with S3 method consistency.
Expand Down
8 changes: 3 additions & 5 deletions R/classical.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ train_classical <- function(.data, formula, specials,
dcmp_op <- switch(type,
additive = "+",
multiplicative = "*")
dcmp_op_inv <- switch(type,
additive = "-",
multiplicative = "/")
cl_sadj <- call2(dcmp_op, sym("trend"), sym("random"))

dcmp <- decompose(ts(y, frequency = m), type = type, ...)[c("trend", "seasonal", "random")]

dcmp <- .data %>%
mutate(
!!!map(dcmp, as.numeric),
season_adjust = !!call2(dcmp_op_inv, sym(resp), sym("seasonal"))
season_adjust = !!cl_sadj
)

seasonalities <- list(
Expand All @@ -42,7 +40,7 @@ train_classical <- function(.data, formula, specials,
aliases <- list2(
!!resp := reduce(syms(c("trend", "seasonal", "random")),
function(x,y) call2(dcmp_op, x, y)),
season_adjust = call2(dcmp_op_inv, sym(resp), sym("seasonal"))
season_adjust = cl_sadj
)

structure(
Expand Down
4 changes: 2 additions & 2 deletions man/generate.stl_decomposition.Rd

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

0 comments on commit 2823121

Please sign in to comment.