-
Notifications
You must be signed in to change notification settings - Fork 31
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
Generating from bootstraps causing .rep clash #296
Milestone
Comments
The key structure needs to update for the conflict resolving column names done by However in the short term, renaming should work without issue: library(fable)
#> Loading required package: fabletools
library(feasts)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
data <- USAccDeaths %>%
as_tsibble()
stl <- data %>%
model(stl = STL(value))
# Bootstrap variants of the data
sim <- stl %>%
generate(new_data = data, times=3)
# Fit models to each bootstrap variant
simulated_fits <- sim %>%
# This can be changed at the tsibble level, or later...
# rename(variant = .rep) %>%
model(ets = ETS(.sim))
# Generate future sample paths from each model
simulated_fits %>%
# Additionally we can retain the model identifier for the bootstrap if we desire
rename(variant = .rep, bootstrap_model = .model) %>%
generate(h=10, times=20)
#> # A tsibble: 600 x 6 [1M]
#> # Key: bootstrap_model, variant, .model, .rep [60]
#> bootstrap_model variant .model index .rep .sim
#> <chr> <chr> <chr> <mth> <chr> <dbl>
#> 1 stl 1 ets 1979 Jan 1 8085.
#> 2 stl 1 ets 1979 Feb 1 7408.
#> 3 stl 1 ets 1979 Mar 1 8398.
#> 4 stl 1 ets 1979 Apr 1 8600.
#> 5 stl 1 ets 1979 May 1 8978.
#> 6 stl 1 ets 1979 Jun 1 10061.
#> 7 stl 1 ets 1979 Jul 1 10491.
#> 8 stl 1 ets 1979 Aug 1 10067.
#> 9 stl 1 ets 1979 Sep 1 8826.
#> 10 stl 1 ets 1979 Oct 1 8953.
#> # … with 590 more rows Created on 2021-01-07 by the reprex package (v0.3.0) |
Related MRE: library(fable)
#> Loading required package: fabletools
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
mdl <- as_tsibble(cbind(mdeaths, fdeaths)) %>%
model(SNAIVE(value))
bind_cols(mdl, as_tibble(mdl)["key"])
#> New names:
#> * key -> key...1
#> * key -> key...3
#> Error: Can't subset columns that don't exist.
#> x Column `key` doesn't exist. Created on 2021-01-07 by the reprex package (v0.3.0) |
mitchelloharawild
added a commit
that referenced
this issue
Jan 7, 2021
Consolidating with #275 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Created on 2020-12-18 by the reprex package (v0.3.0)
Because
.rep
is part of the key structure, just renaming it also causes problems.The text was updated successfully, but these errors were encountered: