Skip to content
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

Non-normally distributed innovations? #380

Open
cryptoguy4561 opened this issue Dec 1, 2022 · 1 comment
Open

Non-normally distributed innovations? #380

cryptoguy4561 opened this issue Dec 1, 2022 · 1 comment

Comments

@cryptoguy4561
Copy link

Wondering if we can specify any non-normally distributed innovation/noise terms. Specifically want to use a t distribution. If not, is there a Python or R package that allows it?

@mitchelloharawild
Copy link
Member

You can provide innovations of any shape to the generate() function via the .innov column of new_data.
https://fabletools.tidyverts.org/reference/generate.mdl_df.html#details

For example,

library(fable)
#> Loading required package: fabletools
library(tsibble)
#> 
#> Attaching package: 'tsibble'
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, union
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
uad <- as_tsibble(USAccDeaths)

fit <- uad %>% 
  model(ETS(value))

innovations <- mutate(new_data(uad, n = 12), .innov = rt(12, 1))

fit %>% 
  generate(new_data = innovations)
#> # A tsibble: 12 x 5 [1M]
#> # Key:       .model, .rep [1]
#>    .model     .rep     index    .innov   .sim
#>    <chr>      <chr>    <mth>     <dbl>  <dbl>
#>  1 ETS(value) 1     1979 Jan   -8.47    8389.
#>  2 ETS(value) 1     1979 Feb -125.      7469.
#>  3 ETS(value) 1     1979 Mar   -0.210   8317.
#>  4 ETS(value) 1     1979 Apr   -0.253   8567.
#>  5 ETS(value) 1     1979 May   -0.744   9363.
#>  6 ETS(value) 1     1979 Jun    1.15    9814.
#>  7 ETS(value) 1     1979 Jul   -3.07   10737.
#>  8 ETS(value) 1     1979 Aug    0.0219 10026.
#>  9 ETS(value) 1     1979 Sep    0.139   8934.
#> 10 ETS(value) 1     1979 Oct   -0.545   9273.
#> 11 ETS(value) 1     1979 Nov   -0.596   8798.
#> 12 ETS(value) 1     1979 Dec    0.142   9004.

Created on 2022-12-02 by the reprex package (v2.0.1)

You can also provide a .rep column to new_data to identify the replicate, allowing multiple paths to be produced from the desired innovations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants