Skip to content

Commit

Permalink
version 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelloharawild authored and cran-robot committed Feb 10, 2024
1 parent 258d60b commit 89aef64
Show file tree
Hide file tree
Showing 26 changed files with 270 additions and 166 deletions.
9 changes: 5 additions & 4 deletions DESCRIPTION
@@ -1,6 +1,6 @@
Package: fabletools
Title: Core Tools for Packages in the 'fable' Framework
Version: 0.3.4
Version: 0.4.0
Authors@R:
c(person(given = "Mitchell",
family = "O'Hara-Wild",
Expand Down Expand Up @@ -35,7 +35,8 @@ Depends: R (>= 3.1.3)
Imports: tsibble (>= 0.9.0), tibble (>= 1.4.1), ggplot2 (>= 3.0.0),
tidyselect, rlang (>= 0.4.5), stats, dplyr (>= 1.0.0), tidyr
(>= 1.1.0), generics, R6, utils, vctrs (>= 0.2.2),
distributional (>= 0.3.0.9000), progressr, lifecycle
distributional (>= 0.3.0.9000), progressr, lifecycle, ggdist,
scales
Suggests: covr, crayon, fable (>= 0.2.0), future, future.apply, knitr,
pillar (>= 1.0.1), feasts (>= 0.1.2), rmarkdown, spelling,
testthat, tsibbledata (>= 0.2.0), lubridate, Matrix
Expand All @@ -46,7 +47,7 @@ Encoding: UTF-8
Language: en-GB
RoxygenNote: 7.2.3
NeedsCompilation: no
Packaged: 2023-10-11 22:19:46 UTC; mitchell
Packaged: 2024-02-09 08:55:27 UTC; mitchell
Author: Mitchell O'Hara-Wild [aut, cre]
(<https://orcid.org/0000-0001-6729-7695>),
Rob Hyndman [aut],
Expand All @@ -56,4 +57,4 @@ Author: Mitchell O'Hara-Wild [aut, cre]
David Holt [ctb]
Maintainer: Mitchell O'Hara-Wild <mail@mitchelloharawild.com>
Repository: CRAN
Date/Publication: 2023-10-11 22:40:02 UTC
Date/Publication: 2024-02-09 09:30:02 UTC
50 changes: 25 additions & 25 deletions MD5
@@ -1,46 +1,46 @@
b92ac3c7fe85d07e97db07e4dbfad422 *DESCRIPTION
d81b95cc2dfb9d0bbeafbe5bd53f741f *NAMESPACE
cc8cb1d9c9c2702901df88c7a7c1d69e *NEWS.md
836b47ffb709e42e5af19f7ecf0d25c3 *DESCRIPTION
0210616e6f9bdb973fe4cccd6444e457 *NAMESPACE
43e113c3e5c7ebde84fe42ee60ea8081 *NEWS.md
6818752e746ee789976f6a5fc64f4aac *R/accessors.R
f625d4399c57190cf6884d66ef627220 *R/accuracy.R
37b47c2ba9cd1581c87da98367e52dd1 *R/aggregate.R
43196b3a91f03002efa4e99f6a94ce8c *R/box_cox.R
905500e19ecb80cb92ca9e328f195949 *R/broom.R
cbaef737d494327d79afb92b21ccf254 *R/compat-purrr.R
c13da3097b071dfdf7af241ac0c22152 *R/broom.R
9c5a925357efa26076bd1576e6535bdb *R/compat-purrr.R
b3d0d03ff262d36d1ca4da9509b6309f *R/components.R
a28cc83ee3ccd2c8df47710b23882cde *R/dable.R
355cc3401ddea9c3460fa4acaf32caa3 *R/definitions.R
9ad0ddbab62e1b98e2505bc165ed6818 *R/dplyr-dable.R
1374c58ef646487f08897d728757ac7f *R/dplyr-fable.R
7252803d29321966bbf4e38726a39d8f *R/dplyr-mable.R
f2d145b381270f5065169e3f72303e3d *R/dplyr-mable.R
f0cfa99a08bf99c3f0b2f8b4ab386305 *R/equation.R
7098a40958f70fe046ac023fe5e08167 *R/estimate.R
90f59f3b44f84ce72d018eb156c3a855 *R/fable.R
72a4c6903b1c47c2c93b204d4237f8a3 *R/fable.R
b457902c3b0168f0c249e7d954d8556f *R/fabletools-package.R
e361446135d80e0d1fbf96e7345ce24e *R/features.R
c7e1cf6c64869618c861edf9977af576 *R/fitted.R
1ffdd17e9c9c8e7421faee45c5da5a66 *R/forecast.R
e1034fba71ee73a44aef1b0fe6c7ae2b *R/fitted.R
d905002ef87b44b261bd5b6a883f6536 *R/forecast.R
45e19ce8bfce438dd436fa5aaf72acbb *R/frequency.R
9015fae450b6f06acae93fac8086ede1 *R/generate.R
6dbd4202a2f0de2202fc735856214508 *R/guess.R
cb5649d99138fb397b05804ce3ad1b2e *R/hilo.R
97184c437f39edcde65c76d9be45c73c *R/hypothesise.R
808cac3af24c00c94c6c8f43293a51a4 *R/hypothesise.R
facafeaa5b00dd81f759ba7499b88f17 *R/interpolate.R
ec7eb945353800bd0a071b15a124538f *R/lst_mdl.R
366d68aa561c46e5a47afa3d0eb1eb02 *R/mable.R
2897bd2b672d7eb85dce27be89ffe4bb *R/mable.R
6cae1fdb6734995e8625daba498c6297 *R/mdl_ts.R
ea1d9ad7b329da5b73adaba42b384fc3 *R/model.R
cfa096eebc6da8b157da7bdd1f951ff5 *R/model_combination.R
0908b1be00a0a52dccb62199b9077da0 *R/model_decomposition.R
238b7f1a0799872f9d05f06b8ead5d21 *R/model.R
38d36b3e9f9fcad47883c59737b581db *R/model_combination.R
6b46dcb9cac798c2119662b9898b2054 *R/model_decomposition.R
df6f7d3d9bcc6fc1a989f7d821aef85c *R/model_null.R
200ccace4ef4ea1dd983923c1d85cf1a *R/outliers.R
e86256a517e92106a6aa58fdaa9294cc *R/outliers.R
b8900f6ace1f6821330f9ea0d7895d96 *R/parse.R
b57d7eda03aa3bf174ea9c39c60b42ea *R/plot.R
519a9ed356888881b56a406f58d4da5c *R/plot.R
eaa9d2eb11683a1ad9302fad722d08a6 *R/reconciliation.R
78a218157cb64bbfb7d306cbdcf181da *R/reexports.R
5a667e2906be16a0a5ef89e790fca772 *R/reexports.R
6bdb5113dd636553aac1aa541cbafb7b *R/refit.R
2ca682e8231f7f02cae0fa4128a134bc *R/report.R
769ed22fb489b0d681c816b58705f808 *R/residuals.R
91dc001a391c2f5b982e586346a21811 *R/residuals.R
fe30a66e973d94f152eeec90864b4a15 *R/response.R
7bdd8bd818a69ab84af685126b4fa632 *R/specials.R
c8d51f09ab597e1c57ce666882e39544 *R/stream.R
Expand All @@ -50,17 +50,17 @@ c65cf167631341af48b62aee71a0bf3f *R/temporal_aggregation.R
8be42bebc26c8ac0c230ce008d9a369f *R/traverse.R
aa2d52dbd3b07f0063bcecf1b0557eb9 *R/utils.R
0f94dbb337a2a8a7e0b6331d412d0975 *R/vctrs-dable.R
7aebf95898f8681650750a219da1ea6f *R/vctrs-fable.R
aa8be00742b8acd10c657e42370096aa *R/vctrs-fable.R
87a711754b6c2b2ae0b0b0569fe15e8f *R/vctrs-mable.R
30c5b8e6b71fb0ca86f7d23370e24c7a *R/xregs.R
9eed4b755fab99446a41a2bb44576600 *R/zzz.R
2aa1613e174051158427cbdb49f32e76 *README.md
278432c795b7edcf701f3f31bfe08654 *build/fabletools.pdf
8c371089775610f37eb6019fe8129a30 *build/fabletools.pdf
d177c79522b967ca3fa9606cbe566aed *build/vignette.rds
184cc9e74fa8f1bd6683d0ff42ed2ded *inst/WORDLIST
21cda36b936f1f388eda39e59d6e611a *inst/doc/extension_models.R
5a159266a4d4a7fc70c5e5702e4ccd9c *inst/doc/extension_models.Rmd
21d6d3e6eb4e0f4f8b2ff67858d2439f *inst/doc/extension_models.html
63b10846090db140aef02cebae2a88b9 *inst/doc/extension_models.html
cff23ee87902f0ba1c751ada29f20fc2 *man/MAAPE.Rd
91c4f419991ef376e144cc6bd8f0637d *man/accuracy.Rd
d2fa9e9eb9773e7276e81d28dcdbb3e8 *man/agg_vec.Rd
Expand All @@ -85,7 +85,7 @@ ad3ec7083e2f5972ee6f1600a949705d *man/common_xregs.Rd
5ef22056d5e4bee3317e8fe464c33aab *man/construct_fc.Rd
da7c8893ae15c0533baab34a2f46a3b1 *man/dable-vctrs.Rd
15f9f26ed1c93dd7002271493b6e2ad3 *man/dable.Rd
b239ede51bf51c71c1782cabb709e532 *man/decomposition_model.Rd
c24366cf630d7dd776ee781a78553334 *man/decomposition_model.Rd
e1f7abf486d9fea0be41bc15437188a4 *man/directional_accuracy_measures.Rd
53a375e40412ae201e85e85515429cc6 *man/distribution_accuracy_measures.Rd
630c282ff1e8b7e32c0eeb8a3c801305 *man/distribution_var.Rd
Expand Down Expand Up @@ -141,7 +141,7 @@ fd11d262287dcffaedb4719e387c59ab *man/outliers.Rd
6447d28ea570f4205ac3f04163adac9f *man/parse_model_rhs.Rd
474792508988b76d6d1ae9ee579932cd *man/point_accuracy_measures.Rd
cb19f90ef22302afe188ec08c93fad05 *man/reconcile.Rd
5ed9e39096f8255deb1c49aabd17f8c3 *man/reexports.Rd
fcba7f0a30e14c54d939a5d9a4d71c55 *man/reexports.Rd
d626054ca8d93616014cad7ea95ed1b2 *man/refit.Rd
7f923d344b049883e5ada968e6330f52 *man/register_feature.Rd
fe74782d2d7a04c98808abda763e18ff *man/report.Rd
Expand All @@ -158,7 +158,7 @@ a51f43537bddd5e20fc9206074bf59e0 *man/scenarios.Rd
7b39011fba1ee026be22079891a239c6 *man/unpack_hilo.Rd
bd30a92d003b45262251d14c254332a4 *man/validate_formula.Rd
8176e3fbb47046d5f7220e147a102483 *tests/testthat.R
6a84e097debdb9c90fec5955d9b46e27 *tests/testthat/Rplots.pdf
e5315afc292886fcb8c99903c980eb5c *tests/testthat/Rplots.pdf
d086dba90b013cec5dda344fb7938612 *tests/testthat/setup-data.R
b93b054b076aba90b60d8f5a0fd9198d *tests/testthat/setup-models.R
6b683cb35b10e316ea6f1d5bcbf69b40 *tests/testthat/test-accuracy.R
Expand All @@ -168,7 +168,7 @@ fe6bbb7d8ad033dd4f3c4658bc1edb3e *tests/testthat/test-decomposition-model.R
5445de0d6ca8a6ebf5e15cdf81c7a14a *tests/testthat/test-fable.R
68676adae765873e84c710e4469d8311 *tests/testthat/test-features.R
110ecf6015c56a0680480e0af09ad5d9 *tests/testthat/test-generate.R
43c858e1aea216118650b2d1067d3b9f *tests/testthat/test-graphics.R
fd9b275e3c1e18a91a0a614df7e8c3a8 *tests/testthat/test-graphics.R
168f179d9969262e0ce4baca71542b6e *tests/testthat/test-hilo.R
5c512358f60a3b13c0f15a11e67a83e4 *tests/testthat/test-interpolate.R
1618029c438b05810e96ba9ae4f72cf9 *tests/testthat/test-mable.R
Expand Down
5 changes: 2 additions & 3 deletions NAMESPACE
Expand Up @@ -139,6 +139,7 @@ S3method(report,null_mdl)
S3method(residuals,"NULL")
S3method(residuals,mdl_df)
S3method(residuals,mdl_ts)
S3method(residuals,model_combination)
S3method(residuals,null_mdl)
S3method(response,mdl_df)
S3method(response,mdl_ts)
Expand Down Expand Up @@ -270,7 +271,6 @@ export(forecast)
export(generate)
export(get_frequencies)
export(glance)
export(guide_level)
export(hfitted)
export(hilo)
export(hypothesize)
Expand Down Expand Up @@ -321,9 +321,7 @@ export(winkler_score)
import(rlang)
import(tsibble)
import(vctrs)
importFrom(distributional,guide_level)
importFrom(distributional,hilo)
importFrom(distributional,scale_level_continuous)
importFrom(dplyr,"%>%")
importFrom(dplyr,anti_join)
importFrom(dplyr,bind_cols)
Expand Down Expand Up @@ -358,6 +356,7 @@ importFrom(generics,interpolate)
importFrom(generics,refit)
importFrom(generics,tidy)
importFrom(ggplot2,aes)
importFrom(ggplot2,after_stat)
importFrom(ggplot2,autolayer)
importFrom(ggplot2,autoplot)
importFrom(ggplot2,facet_grid)
Expand Down
9 changes: 9 additions & 0 deletions NEWS.md
@@ -1,3 +1,12 @@
# fabletools 0.4.0

## Improvements

* Improved handling of `combination_model()` when used with transformed
component models.
* `autoplot(<fbl_ts>)`, `autolayer(<fbl_ts>)` and `autoplot(<dcmp_ts>)` now use
the ggdist package visualising uncertainty with distributional vectors.

# fabletools 0.3.4

## New features
Expand Down
4 changes: 2 additions & 2 deletions R/broom.R
Expand Up @@ -94,7 +94,7 @@ glance.mdl_df <- function(x, ...){
mbl_vars <- mable_vars(x)
x <- mutate(as_tibble(x),
dplyr::across(all_of(mbl_vars), function(x) lapply(x, glance, ...)))
x <- pivot_longer(x, mbl_vars, names_to = ".model", values_to = ".glanced")
x <- pivot_longer(x, all_of(mbl_vars), names_to = ".model", values_to = ".glanced")
unnest(x, ".glanced")
}

Expand Down Expand Up @@ -126,7 +126,7 @@ tidy.mdl_df <- function(x, ...){
mbl_vars <- mable_vars(x)
x <- mutate(as_tibble(x),
dplyr::across(all_of(mbl_vars), function(x) lapply(x, tidy, ...)))
x <- pivot_longer(x, mbl_vars, names_to = ".model", values_to = ".tidied")
x <- pivot_longer(x, all_of(mbl_vars), names_to = ".model", values_to = ".tidied")
unnest(x, ".tidied")
}

Expand Down
9 changes: 9 additions & 0 deletions R/compat-purrr.R
Expand Up @@ -201,4 +201,13 @@ compose <- function (...) {
out
}
}

flatten <- function(x) {
unlist(x, recursive = FALSE)
}

squash <- function(x) {
unlist(x, recursive = TRUE)
}

# nocov end
6 changes: 3 additions & 3 deletions R/dplyr-mable.R
@@ -1,7 +1,7 @@
#' @export
dplyr_row_slice.mdl_df <- function(data, i, ..., preserve = FALSE) {
res <- dplyr_row_slice(as_tibble(data), i, ..., preserve = preserve)
build_mable(res, key = !!key_vars(data), model = !!mable_vars(data))
build_mable(res, key = !!key_vars(data), model = mable_vars(data))
}

#' @export
Expand All @@ -15,7 +15,7 @@ dplyr_col_modify.mdl_df <- function(data, cols) {
# }
build_mable(res,
key = !!key_vars(data),
model = !!union(mable_vars(data), names(which(is_mdl))))
model = union(mable_vars(data), names(which(is_mdl))))
}

#' @export
Expand All @@ -24,7 +24,7 @@ dplyr_reconstruct.mdl_df <- function(data, template) {
mbl_vars <- names(which(vapply(data, inherits, logical(1L), "lst_mdl")))
kv <- key_vars(template)
if(all(kv %in% names(res))) {
build_mable(data, key = !!kv, model = !!mbl_vars)
build_mable(data, key = !!kv, model = mbl_vars)
} else {
as_tibble(res)
}
Expand Down
31 changes: 19 additions & 12 deletions R/fable.R
Expand Up @@ -12,7 +12,14 @@
#'
#' @export
fable <- function(..., response, distribution){
build_fable(tsibble(...), !!enquo(response), !!enquo(distribution))
# Create tsibble from ... inputs
x <- tsibble(...)

# If the response (from user input) needs converting
response <- eval_tidy(enquo(response))
distribution <- names(x)[tidyselect::eval_select(enquo(distribution), x)]

build_fable(x, response, distribution)
}

#' Is the object a fable
Expand All @@ -39,9 +46,11 @@ as_fable <- function(x, ...){
#' @rdname as-fable
#' @export
as_fable.tbl_ts <- function(x, response, distribution, ...){
build_fable(x,
response = !!enquo(response),
distribution = !!enquo(distribution))
# If the response (from user input) needs converting
response <- eval_tidy(enquo(response))
distribution <- names(x)[tidyselect::eval_select(enquo(distribution), x)]

build_fable(x, response = response, distribution = distribution)
}

#' @rdname as-fable
Expand All @@ -51,9 +60,11 @@ as_fable.grouped_ts <- as_fable.tbl_ts
#' @rdname as-fable
#' @export
as_fable.tbl_df <- function(x, response, distribution, ...){
build_fable(as_tsibble(x, ...),
response = !!enquo(response),
distribution = !!enquo(distribution))
as_fable(
as_tsibble(x, ...),
response = !!enquo(response),
distribution = !!enquo(distribution)
)
}

#' @rdname as-fable
Expand Down Expand Up @@ -121,10 +132,6 @@ as_fable.forecast <- function(x, ..., point_forecast = list(.mean = mean)){
}

build_fable <- function (x, response, distribution) {
# If the response (from user input) needs converting
response <- eval_tidy(enquo(response))
distribution <- names(x)[tidyselect::eval_select(enquo(distribution), x)]

if(is_grouped_ts(x)){
fbl <- structure(x, class = c("grouped_fbl", "grouped_ts", "grouped_df",
"fbl_ts", "tbl_ts", "tbl_df", "tbl", "data.frame"),
Expand Down Expand Up @@ -199,7 +206,7 @@ restore_fable <- function(data, template){
fbl_vars <- setdiff(distribution_var(template), data_cols)
res <- bind_cols(data, template[fbl_vars])

build_fable(data, response = response_vars(template), distribution = !!distribution_var(template))
build_fable(data, response = response_vars(template), distribution = distribution_var(template))
}

#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/fitted.R
Expand Up @@ -16,7 +16,7 @@ fitted.mdl_df <- function(object, ...){
kv <- key_vars(object)
object <- mutate(as_tibble(object),
dplyr::across(all_of(mbl_vars), function(x) lapply(x, fitted, ...)))
object <- pivot_longer(object, mbl_vars, names_to = ".model", values_to = ".fitted")
object <- pivot_longer(object, all_of(mbl_vars), names_to = ".model", values_to = ".fitted")
unnest_tsbl(object, ".fitted", parent_key = c(kv, ".model"))
}

Expand Down
4 changes: 2 additions & 2 deletions R/forecast.R
Expand Up @@ -156,7 +156,7 @@ forecast.mdl_ts <- function(object, new_data = NULL, h = NULL, bias_adjust = NUL
# If there's nothing to forecast, return an empty fable.
if(NROW(new_data) == 0){
new_data[[dist_col]] <- distributional::new_dist(dimnames = resp_vars)
fbl <- build_fable(new_data, response = resp_vars, distribution = !!sym(dist_col))
fbl <- build_fable(new_data, response = resp_vars, distribution = dist_col)
return(fbl)
}
# Compute forecasts
Expand Down Expand Up @@ -246,7 +246,7 @@ forecast.mdl_ts <- function(object, new_data = NULL, h = NULL, bias_adjust = NUL
interval = interval(new_data)
)

build_fable(fbl, response = resp_vars, distribution = !!sym(dist_col))
build_fable(fbl, response = resp_vars, distribution = dist_col)
}

#' Construct a new set of forecasts
Expand Down
2 changes: 1 addition & 1 deletion R/hypothesise.R
Expand Up @@ -21,7 +21,7 @@ hypothesize.mdl_df <- function(x, ...){
mbl_vars <- mable_vars(x)
x <- mutate(as_tibble(x),
dplyr::across(all_of(mbl_vars), function(x) lapply(x, hypothesize, ...)))
x <- pivot_longer(x, mbl_vars, names_to = ".model", values_to = ".hypothesis")
x <- pivot_longer(x, all_of(mbl_vars), names_to = ".model", values_to = ".hypothesis")
unnest(x, ".hypothesis")
}

Expand Down

0 comments on commit 89aef64

Please sign in to comment.