diff --git a/DESCRIPTION b/DESCRIPTION index 24ac650..85d01ea 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: fabletools Title: Core Tools for Packages in the 'fable' Framework -Version: 0.4.0 +Version: 0.4.1 Authors@R: c(person(given = "Mitchell", family = "O'Hara-Wild", @@ -47,7 +47,7 @@ Encoding: UTF-8 Language: en-GB RoxygenNote: 7.2.3 NeedsCompilation: no -Packaged: 2024-02-09 08:55:27 UTC; mitchell +Packaged: 2024-03-02 06:30:29 UTC; mitchell Author: Mitchell O'Hara-Wild [aut, cre] (), Rob Hyndman [aut], @@ -57,4 +57,4 @@ Author: Mitchell O'Hara-Wild [aut, cre] David Holt [ctb] Maintainer: Mitchell O'Hara-Wild Repository: CRAN -Date/Publication: 2024-02-09 09:30:02 UTC +Date/Publication: 2024-03-02 07:12:35 UTC diff --git a/MD5 b/MD5 index 2979765..5facb22 100644 --- a/MD5 +++ b/MD5 @@ -1,8 +1,8 @@ -836b47ffb709e42e5af19f7ecf0d25c3 *DESCRIPTION +b31c2ecadaa4761611091e2334471584 *DESCRIPTION 0210616e6f9bdb973fe4cccd6444e457 *NAMESPACE -43e113c3e5c7ebde84fe42ee60ea8081 *NEWS.md +5a486f267f38ac8109a26a702abce399 *NEWS.md 6818752e746ee789976f6a5fc64f4aac *R/accessors.R -f625d4399c57190cf6884d66ef627220 *R/accuracy.R +237856f3b62750ab6177ba97171139f3 *R/accuracy.R 37b47c2ba9cd1581c87da98367e52dd1 *R/aggregate.R 43196b3a91f03002efa4e99f6a94ce8c *R/box_cox.R c13da3097b071dfdf7af241ac0c22152 *R/broom.R @@ -17,11 +17,11 @@ f0cfa99a08bf99c3f0b2f8b4ab386305 *R/equation.R 7098a40958f70fe046ac023fe5e08167 *R/estimate.R 72a4c6903b1c47c2c93b204d4237f8a3 *R/fable.R b457902c3b0168f0c249e7d954d8556f *R/fabletools-package.R -e361446135d80e0d1fbf96e7345ce24e *R/features.R +2eb93fb9d4974a49708aac7dbbbed0c0 *R/features.R e1034fba71ee73a44aef1b0fe6c7ae2b *R/fitted.R d905002ef87b44b261bd5b6a883f6536 *R/forecast.R 45e19ce8bfce438dd436fa5aaf72acbb *R/frequency.R -9015fae450b6f06acae93fac8086ede1 *R/generate.R +9179dd6821b75ce09d2b7a799f7863fe *R/generate.R 6dbd4202a2f0de2202fc735856214508 *R/guess.R cb5649d99138fb397b05804ce3ad1b2e *R/hilo.R 808cac3af24c00c94c6c8f43293a51a4 *R/hypothesise.R @@ -29,13 +29,13 @@ facafeaa5b00dd81f759ba7499b88f17 *R/interpolate.R ec7eb945353800bd0a071b15a124538f *R/lst_mdl.R 2897bd2b672d7eb85dce27be89ffe4bb *R/mable.R 6cae1fdb6734995e8625daba498c6297 *R/mdl_ts.R -238b7f1a0799872f9d05f06b8ead5d21 *R/model.R +b72a03176431ac6a51801f74f11a1388 *R/model.R 38d36b3e9f9fcad47883c59737b581db *R/model_combination.R 6b46dcb9cac798c2119662b9898b2054 *R/model_decomposition.R df6f7d3d9bcc6fc1a989f7d821aef85c *R/model_null.R e86256a517e92106a6aa58fdaa9294cc *R/outliers.R b8900f6ace1f6821330f9ea0d7895d96 *R/parse.R -519a9ed356888881b56a406f58d4da5c *R/plot.R +d53c0054e0ea4d63564e4156981e545a *R/plot.R eaa9d2eb11683a1ad9302fad722d08a6 *R/reconciliation.R 5a667e2906be16a0a5ef89e790fca772 *R/reexports.R 6bdb5113dd636553aac1aa541cbafb7b *R/refit.R @@ -48,14 +48,14 @@ cbdf350bf426c9729a4078546d47e95c *R/tbl_utils.R c65cf167631341af48b62aee71a0bf3f *R/temporal_aggregation.R 29d85cdb4a12aab1de17e06c942613d9 *R/transform.R 8be42bebc26c8ac0c230ce008d9a369f *R/traverse.R -aa2d52dbd3b07f0063bcecf1b0557eb9 *R/utils.R +7fb37bd8075c4a03801fb8df217cc42c *R/utils.R 0f94dbb337a2a8a7e0b6331d412d0975 *R/vctrs-dable.R aa8be00742b8acd10c657e42370096aa *R/vctrs-fable.R 87a711754b6c2b2ae0b0b0569fe15e8f *R/vctrs-mable.R 30c5b8e6b71fb0ca86f7d23370e24c7a *R/xregs.R 9eed4b755fab99446a41a2bb44576600 *R/zzz.R 2aa1613e174051158427cbdb49f32e76 *README.md -8c371089775610f37eb6019fe8129a30 *build/fabletools.pdf +f9c777395eae7f8fdc2f636f339403e0 *build/fabletools.pdf d177c79522b967ca3fa9606cbe566aed *build/vignette.rds 184cc9e74fa8f1bd6683d0ff42ed2ded *inst/WORDLIST 21cda36b936f1f388eda39e59d6e611a *inst/doc/extension_models.R @@ -94,7 +94,7 @@ a0fdb24d9d15c5c5630de61a05615a2e *man/estimate.Rd c23404d1cf73d4a9f55c8de604b7afcf *man/fable.Rd 6fa75a3a106ae574c873cfdfe3750196 *man/fabletools-package.Rd 0103d444a1b6f7328765a533af6d6553 *man/feature_set.Rd -8f93b5d113ffbb7ad4448bbd22c4b0e8 *man/features.Rd +2d0b51cadb0e0cdb43ccbaa891aef3d2 *man/features.Rd fa0df8e7f6421e888cb51933c92f5352 *man/features_by_pkg.Rd e9919790bfeaea0be100337ec906e06b *man/features_by_tag.Rd cdb7be9efaa25f3cca4cf33ade6e1394 *man/figures/README-example-1.png @@ -112,11 +112,11 @@ c3978703d8f40f2679795335715e98f4 *man/figures/lifecycle-experimental.svg a02805f10249e06ffd570832856db160 *man/fitted.mdl_df.Rd 700c2451db953723da1019dfeeae6320 *man/forecast.Rd 676fd82e0d71779c4d0a82460c183616 *man/freq_tools.Rd -f64be4ec92640f545c0ac84afcffa922 *man/generate.mdl_df.Rd +dddabb76edd8c4422f4966b1ca0601d2 *man/generate.mdl_df.Rd 3c866d37bd834c880c4d0acdb467c242 *man/glance.Rd 402005ae22c3b3c3f28792fc1fbd2962 *man/hypothesize.mdl_df.Rd a7ef1ffd6ae8a8dc68ab2700620e13b0 *man/interpolate.Rd -e8a5223160a4a939cd6dd5a59676f30f *man/interval_accuracy_measures.Rd +83a7285e9e484fa5cbebc6c155795728 *man/interval_accuracy_measures.Rd b9c7fa4747f3a212a0b7853b21f807a5 *man/is_aggregated.Rd 96062f4c4b65037642ec23dfa30ad05e *man/is_dable.Rd b6ba18a3867cf077b10e8fc0bf563121 *man/is_fable.Rd @@ -158,10 +158,10 @@ a51f43537bddd5e20fc9206074bf59e0 *man/scenarios.Rd 7b39011fba1ee026be22079891a239c6 *man/unpack_hilo.Rd bd30a92d003b45262251d14c254332a4 *man/validate_formula.Rd 8176e3fbb47046d5f7220e147a102483 *tests/testthat.R -e5315afc292886fcb8c99903c980eb5c *tests/testthat/Rplots.pdf +90b5cfd83a2b5f510a9952f77ad43286 *tests/testthat/Rplots.pdf d086dba90b013cec5dda344fb7938612 *tests/testthat/setup-data.R b93b054b076aba90b60d8f5a0fd9198d *tests/testthat/setup-models.R -6b683cb35b10e316ea6f1d5bcbf69b40 *tests/testthat/test-accuracy.R +78be627b30c035011df6310957ebaddf *tests/testthat/test-accuracy.R 8eb061a803272c60a11e1b0ccea320d2 *tests/testthat/test-broom.R e9703e4c2e172e3e7ad599b51641c9b6 *tests/testthat/test-combination.R fe6bbb7d8ad033dd4f3c4658bc1edb3e *tests/testthat/test-decomposition-model.R diff --git a/NEWS.md b/NEWS.md index 740250a..5b34aa7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,13 @@ +# fabletools 0.4.1 + +Minor patch for upcoming release of ggdist v3.3.1 + +## Improvements + +* Added (scaled) pinball loss metrics to `interval_accuracy_measures` (#379). +* Improved use of random seed in parallel modelling and forecasting (#384). +* Documentation improvements + # fabletools 0.4.0 ## Improvements diff --git a/R/accuracy.R b/R/accuracy.R index f5c552d..b4467a6 100644 --- a/R/accuracy.R +++ b/R/accuracy.R @@ -224,7 +224,7 @@ scaled_pinball_loss <- function(.dist, .actual, .train, level = 95, na.rm = TRUE #' @param level The level of the forecast interval. #' #' @export -interval_accuracy_measures <- list(winkler = winkler_score) +interval_accuracy_measures <- list(winkler = winkler_score, pinball = pinball_loss, scaled_pinball = scaled_pinball_loss) #' @rdname distribution_accuracy_measures #' @export diff --git a/R/features.R b/R/features.R index b29c135..fa34522 100644 --- a/R/features.R +++ b/R/features.R @@ -89,7 +89,8 @@ features_impl <- function(.tbl, .var, features, ...){ #' - [Features by tag][features_by_tag] #' #' @param .tbl A dataset -#' @param .var,.vars The variable(s) to compute features on +#' @param .var An expression that produces a vector from which the features are computed. +#' @param .vars A tidyselect compatible selection of the column(s) to compute features on. #' @param features A list of functions (or lambda expressions) for the features to compute. [`feature_set()`] is a useful helper for building sets of features. #' @param .predicate A predicate function (or lambda expression) to be applied to the columns or a logical vector. The variables for which .predicate is or returns TRUE are selected. #' @param ... Additional arguments to be passed to each feature. These arguments will only be passed to features which use it in their formal arguments ([`base::formals()`]), and not via their `...`. While passing `na.rm = TRUE` to [`stats::var()`] will work, it will not for [`base::mean()`] as its formals are `x` and `...`. To more precisely pass inputs to each function, you should use lambdas in the list of features (`~ mean(., na.rm = TRUE)`). diff --git a/R/generate.R b/R/generate.R index 843ef15..6ce9f60 100644 --- a/R/generate.R +++ b/R/generate.R @@ -2,7 +2,7 @@ #' #' Use a model's fitted distribution to simulate additional data with similar #' behaviour to the response. This is a tidy implementation of -#' `\link[stats]{simulate}`. +#' [stats::simulate()]. #' #' Innovations are sampled by the model's assumed error distribution. #' If `bootstrap` is `TRUE`, innovations will be sampled from the model's diff --git a/R/model.R b/R/model.R index 7e0cab4..a29b63a 100644 --- a/R/model.R +++ b/R/model.R @@ -105,7 +105,8 @@ Check that specified model(s) are model definitions.", nm[which(!is_mdl)[1]])) rep(models, each = length(lst_data)), FUN = estimate_progress, SIMPLIFY = FALSE, - future.globals = FALSE + future.globals = FALSE, + future.seed = TRUE ) unname(split(out, rep(seq_len(num_mdl), each = num_key))) } diff --git a/R/plot.R b/R/plot.R index 3eacdf7..5d59306 100644 --- a/R/plot.R +++ b/R/plot.R @@ -318,9 +318,13 @@ build_fbl_layer <- function(object, data = NULL, level = c(80, 95), } # Apply ramped fill if (!is.null(data[["fill_ramp"]])) { - data$fill = mapply(function(color, amount){ - (scales::seq_gradient_pal(attr(amount, "from") %||% "white", color))(amount %||% NA) - }, data$fill, data$fill_ramp) + if (utils::packageVersion("ggdist") > "3.3.1") { + data$fill <- get0("ramp_colours", asNamespace("ggdist"), mode = "function")(data$fill, data$fill_ramp) + } else { + data$fill <- mapply(function(color, amount){ + (scales::seq_gradient_pal(attr(amount, "from") %||% "white", color))(amount %||% NA) + }, data$fill, data$fill_ramp) + } } ggplot2::draw_key_rect(data, params, size) } diff --git a/R/utils.R b/R/utils.R index 1aedd6d..b7bc4ee 100644 --- a/R/utils.R +++ b/R/utils.R @@ -264,7 +264,8 @@ mapply_maybe_parallel <- function (.f, ..., MoreArgs = list(), SIMPLIFY = FALSE) ..., MoreArgs = MoreArgs, SIMPLIFY = SIMPLIFY, - future.globals = FALSE + future.globals = FALSE, + future.seed = TRUE ) } else{ diff --git a/build/fabletools.pdf b/build/fabletools.pdf index fc37ee3..7ed16bd 100644 Binary files a/build/fabletools.pdf and b/build/fabletools.pdf differ diff --git a/man/features.Rd b/man/features.Rd index b6ad11b..7f145b0 100644 --- a/man/features.Rd +++ b/man/features.Rd @@ -18,12 +18,14 @@ features_if(.tbl, .predicate, features, ...) \arguments{ \item{.tbl}{A dataset} -\item{.var, .vars}{The variable(s) to compute features on} +\item{.var}{An expression that produces a vector from which the features are computed.} \item{features}{A list of functions (or lambda expressions) for the features to compute. \code{\link[=feature_set]{feature_set()}} is a useful helper for building sets of features.} \item{...}{Additional arguments to be passed to each feature. These arguments will only be passed to features which use it in their formal arguments (\code{\link[base:formals]{base::formals()}}), and not via their \code{...}. While passing \code{na.rm = TRUE} to \code{\link[stats:cor]{stats::var()}} will work, it will not for \code{\link[base:mean]{base::mean()}} as its formals are \code{x} and \code{...}. To more precisely pass inputs to each function, you should use lambdas in the list of features (\code{~ mean(., na.rm = TRUE)}).} +\item{.vars}{A tidyselect compatible selection of the column(s) to compute features on.} + \item{.predicate}{A predicate function (or lambda expression) to be applied to the columns or a logical vector. The variables for which .predicate is or returns TRUE are selected.} } \description{ diff --git a/man/generate.mdl_df.Rd b/man/generate.mdl_df.Rd index b59a739..d60184b 100644 --- a/man/generate.mdl_df.Rd +++ b/man/generate.mdl_df.Rd @@ -39,7 +39,7 @@ time series with no exogenous regressors).} \description{ Use a model's fitted distribution to simulate additional data with similar behaviour to the response. This is a tidy implementation of -\verb{\link[stats]\{simulate\}}. +\code{\link[stats:simulate]{stats::simulate()}}. } \details{ Innovations are sampled by the model's assumed error distribution. diff --git a/man/interval_accuracy_measures.Rd b/man/interval_accuracy_measures.Rd index 260acdc..19ded5f 100644 --- a/man/interval_accuracy_measures.Rd +++ b/man/interval_accuracy_measures.Rd @@ -8,7 +8,7 @@ \alias{interval_accuracy_measures} \title{Interval estimate accuracy measures} \format{ -An object of class \code{list} of length 1. +An object of class \code{list} of length 3. } \usage{ winkler_score(.dist, .actual, level = 95, na.rm = TRUE, ...) diff --git a/tests/testthat/Rplots.pdf b/tests/testthat/Rplots.pdf index c26028f..4ca89b8 100644 Binary files a/tests/testthat/Rplots.pdf and b/tests/testthat/Rplots.pdf differ diff --git a/tests/testthat/test-accuracy.R b/tests/testthat/test-accuracy.R index b7212d1..06ab4c2 100644 --- a/tests/testthat/test-accuracy.R +++ b/tests/testthat/test-accuracy.R @@ -88,7 +88,7 @@ test_that("Out-of-sample accuracy", { acc <- accuracy(fbl, us_deaths, measures = list(interval_accuracy_measures, distribution_accuracy_measures)) expect_equal(acc$.type, "Test") - expect_equal(colnames(acc), c(".model", ".type", "winkler", "percentile", "CRPS")) + expect_equal(colnames(acc), c(".model", ".type", "winkler", "pinball", "scaled_pinball", "percentile", "CRPS")) expect_true(!any(map_lgl(acc, compose(any, is.na)))) acc_multi <- accuracy(fbl_multi, lung_deaths_long)