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

Error step_fourier in training(splits) #220

Open
maironchaves opened this issue Nov 30, 2022 · 0 comments
Open

Error step_fourier in training(splits) #220

maironchaves opened this issue Nov 30, 2022 · 0 comments

Comments

@maironchaves
Copy link

Hello!

I have the following error when using the step_fourier function. This error only occurs when I use time_series_split split with my data to convert paneled time series into training and testing sets. When I input the dataset directly, the error does not occur.

Here the error occurs:

library(recipes)
library(tidyverse)
library(tidyquant)
library(timetk)


dados <- FANG  %>% select(symbol,date,volume)

splits <- dados %>% 
  time_series_split(
    assess     = "1 months", 
    cumulative = TRUE
  )


rec_obj <- recipe(volume ~ ., data = training(splits)) %>%
  
  step_fourier(date,period=365, K = 1)



rec_obj %>% prep() %>% juice() %>% glimpse()

Follow the error:

    Rows: 3,948
    Columns: 5
    $ symbol         <fct> FB, AMZN, NFLX, GOOG, FB, AMZN, NFLX, GOOG, FB, AMZN,…
    $ date           <date> 2013-01-02, 2013-01-02, 2013-01-02, 2013-01-02, 2013…
    $ volume         <dbl> 69846400, 3271000, 19431300, 5101500, 63140600, 27509…
    $ date_sin365_K1 <dbl> NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN…
    $ date_cos365_K1 <dbl> NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN…
    Warning messages:
    1: Problem while computing `date_sin365_K1 = timetk::fourier_vec(...)`.
    ℹ NaNs produced 
    2: Problem while computing `date_cos365_K1 = timetk::fourier_vec(...)`.
    ℹ NaNs produced 

Here the error does not occur:

library(recipes)
library(tidyverse)
library(tidyquant)
library(timetk)

dados <- FANG  %>% select(symbol,date,volume)



rec_obj <- recipe(volume ~ ., data = dados) %>%
  
  step_fourier(date,period=365, K = 1)



rec_obj %>% prep() %>% juice() %>% glimpse()

Rows: 4,032
Columns: 5
$ symbol         <fct> FB, FB, FB, FB, FB, FB, FB, FB, FB, FB, FB, FB, FB, F…
$ date           <date> 2013-01-02, 2013-01-03, 2013-01-04, 2013-01-07, 2013…
$ volume         <dbl> 69846400, 63140600, 72715400, 83781800, 45871300, 104…
$ date_sin365_K1 <dbl> 0.2051045, 0.2219215, 0.2386728, 0.2884824, 0.3049212…
$ date_cos365_K1 <dbl> 0.9787401, 0.9750645, 0.9711001, 0.9574852, 0.9523776…
> 

Can anyone please help me?

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

1 participant