Closed Fuco1 closed 3 years ago
Works for me. Try installing the latest version of fabletools from CRAN.
library(tibble)
library(tsibble)
library(fable)
#> Loading required package: fabletools
library(fabletools)
library(lubridate)
#>
#> Attaching package: 'lubridate'
#> The following object is masked from 'package:tsibble':
#>
#> interval
#> The following objects are masked from 'package:base':
#>
#> date, intersect, setdiff, union
library(distributional)
tibble(
.model = "test",
date = yearmonth(ymd('2019-01-01') + months(1:12 - 1)),
quantity = dist_normal(1:12 * 10, sqrt(1:12) * 5),
.mean = 10
) %>%
as_tsibble(key = ".model") %>%
as_fable(response = ".mean", distribution = quantity)
#> Using `date` as index variable.
#> Warning: The dimnames of the fable's distribution are missing and have been set
#> to match the response variables.
#> # A fable: 12 x 4 [1M]
#> # Key: .model [1]
#> .model date quantity .mean
#> <chr> <mth> <dist> <dbl>
#> 1 test 2019 Jan N(10, 25) 10
#> 2 test 2019 Feb N(20, 50) 10
#> 3 test 2019 Mar N(30, 75) 10
#> 4 test 2019 Apr N(40, 100) 10
#> 5 test 2019 May N(50, 125) 10
#> 6 test 2019 Jun N(60, 150) 10
#> 7 test 2019 Jul N(70, 175) 10
#> 8 test 2019 Aug N(80, 200) 10
#> 9 test 2019 Sep N(90, 225) 10
#> 10 test 2019 Oct N(100, 250) 10
#> 11 test 2019 Nov N(110, 275) 10
#> 12 test 2019 Dec N(120, 300) 10
Created on 2020-09-07 by the reprex package (v0.3.0)
Yep, I was on 2.0.something devel version, after updating it works. Sorry for the noise!
When I try to turn a tsibble into a fable using
as_fable
I get this odd error:The thing is that when I look at an output of
forecast
the column looks the same and is written out as<dist>
which I think is this type. To be honest I quite fail to understand thevctrs
package but I thought that distributions, models, hilos etc are "vectors" by default (hence they print as<distribution[n]>
wheren
is the length).I think this should be a complete repro case (might need to load some additional package but I'm sure you have them all somewhere on your system :))