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

Warnings/Errors when Running the Examples to Tune the Parameters #10

Open
larry77 opened this issue Aug 11, 2022 · 2 comments
Open

Warnings/Errors when Running the Examples to Tune the Parameters #10

larry77 opened this issue Aug 11, 2022 · 2 comments

Comments

@larry77
Copy link

larry77 commented Aug 11, 2022

Hello

Please have a look at the reprex below. It is essentially the example at

https://albertoalmuinha.github.io/garchmodels/articles/tuning_univariate_algorithms.html

I get some warning and error messages, in particular when tuning the model on various slices of the data.

  1. Is is anything to worry about? and
  2. If so, can it be fixed?

Thanks a lot!

library(garchmodels)
#> Loading required package: parsnip
#> Loading required package: rugarch
#> Loading required package: parallel
#> 
#> Attaching package: 'rugarch'
#> The following object is masked from 'package:stats':
#> 
#>     sigma
#> Loading required package: rmgarch
library(timetk)
library(tidyverse)
#> Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
#> Also defined by 'Rmpfr'
#> Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
#> Also defined by 'Rmpfr'
#> Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
#> Also defined by 'Rmpfr'
#> Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
#> Also defined by 'Rmpfr'
#> Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
#> Also defined by 'Rmpfr'
#> Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
#> Also defined by 'Rmpfr'
#> Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
#> Also defined by 'Rmpfr'
#> Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
#> Also defined by 'Rmpfr'
#> Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
#> Also defined by 'Rmpfr'
#> Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
#> Also defined by 'Rmpfr'
#> Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
#> Also defined by 'Rmpfr'
#> Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
#> Also defined by 'Rmpfr'
library(tidymodels)

rIBM
#> # A tibble: 3,523 × 2
#>    date       daily_returns
#>    <date>             <dbl>
#>  1 2007-01-03      0.000926
#>  2 2007-01-04      0.0107  
#>  3 2007-01-05     -0.00905 
#>  4 2007-01-08      0.0152  
#>  5 2007-01-09      0.0118  
#>  6 2007-01-10     -0.0118  
#>  7 2007-01-11     -0.00243 
#>  8 2007-01-12      0.00699 
#>  9 2007-01-16      0.0149  
#> 10 2007-01-17     -0.00793 
#> # … with 3,513 more rows
#> # ℹ Use `print(n = ...)` to see more rows

rIBM_extended <- rIBM %>%
    future_frame(.length_out = 3, .bind_data = TRUE) 
#> .date_var is missing. Using: date

rIBM_train  <- rIBM_extended %>% drop_na()
rIBM_future <- rIBM_extended %>% filter(is.na(daily_returns))


# Model Spec
model_spec <-garchmodels::garch_reg(mode = "regression",
                                    arch_order = tune(),
                                    garch_order = tune(),
                                    tune_by = "sigmaFor") %>%
    set_engine("rugarch")



# Recipe spec
recipe_spec <- recipe(daily_returns ~ date, data = rIBM_train)


# Workflow
wflw <- workflow() %>%
    add_recipe(recipe_spec) %>%
    add_model(model_spec)


resamples <- timetk::time_series_cv(rIBM_train, 
                                    date_var = date, 
                                    initial = "6 years", 
                                    assess = "24 months",
                                    skip = "24 months",
                                    cumulative = TRUE,
                                    slice_limit = 3)

## timetk::plot_time_series_cv_plan(resamples, .date_var = date, .value = daily_returns)



tune_results <- tune_grid(
    object     = wflw,
    resamples  = resamples,
    param_info = parameters(wflw),
    grid       = 5,
    control    = control_grid(verbose = TRUE, allow_par = TRUE, parallel_over = "everything")
)
#> Warning: `parameters.workflow()` was deprecated in tune 0.1.6.9003.
#> Please use `hardhat::extract_parameter_set_dials()` instead.
#> i Slice1: preprocessor 1/1
#> ✓ Slice1: preprocessor 1/1
#> i Slice1: preprocessor 1/1, model 1/5
#> frequency = 5 observations per 1 week
#> ✓ Slice1: preprocessor 1/1, model 1/5
#> i Slice1: preprocessor 1/1, model 1/5 (predictions)
#> i Slice1: preprocessor 1/1
#> ✓ Slice1: preprocessor 1/1
#> i Slice1: preprocessor 1/1, model 2/5
#> frequency = 5 observations per 1 week
#> ✓ Slice1: preprocessor 1/1, model 2/5
#> i Slice1: preprocessor 1/1, model 2/5 (predictions)
#> i Slice1: preprocessor 1/1
#> ✓ Slice1: preprocessor 1/1
#> i Slice1: preprocessor 1/1, model 3/5
#> frequency = 5 observations per 1 week
#> ✓ Slice1: preprocessor 1/1, model 3/5
#> i Slice1: preprocessor 1/1, model 3/5 (predictions)
#> i Slice1: preprocessor 1/1
#> ✓ Slice1: preprocessor 1/1
#> i Slice1: preprocessor 1/1, model 4/5
#> frequency = 5 observations per 1 week
#> x Slice1: preprocessor 1/1, model 4/5:
#>   Error in `modeltime::new_modeltime_bridge()`:
#>   ! 'data' does not have 4 columns
#>   
#>   'data' should be a data frame (or tibble) containing 4 columns:
#>    1. date column (with name that matches input data)
#>    2. .actual (these are the original values your model trains from)
#>    3. .fitted (these are your model's in-sample training results)
#>    4. .residuals (these are your model's in-sample errors)
#> i Slice1: preprocessor 1/1
#> ✓ Slice1: preprocessor 1/1
#> i Slice1: preprocessor 1/1, model 5/5
#> frequency = 5 observations per 1 week
#> ✓ Slice1: preprocessor 1/1, model 5/5
#> i Slice1: preprocessor 1/1, model 5/5 (predictions)
#> i Slice2: preprocessor 1/1
#> ✓ Slice2: preprocessor 1/1
#> i Slice2: preprocessor 1/1, model 1/5
#> frequency = 5 observations per 1 week
#> ✓ Slice2: preprocessor 1/1, model 1/5
#> i Slice2: preprocessor 1/1, model 1/5 (predictions)
#> i Slice2: preprocessor 1/1
#> ✓ Slice2: preprocessor 1/1
#> i Slice2: preprocessor 1/1, model 2/5
#> frequency = 5 observations per 1 week
#> ✓ Slice2: preprocessor 1/1, model 2/5
#> i Slice2: preprocessor 1/1, model 2/5 (predictions)
#> i Slice2: preprocessor 1/1
#> ✓ Slice2: preprocessor 1/1
#> i Slice2: preprocessor 1/1, model 3/5
#> frequency = 5 observations per 1 week
#> ✓ Slice2: preprocessor 1/1, model 3/5
#> i Slice2: preprocessor 1/1, model 3/5 (predictions)
#> i Slice2: preprocessor 1/1
#> ✓ Slice2: preprocessor 1/1
#> i Slice2: preprocessor 1/1, model 4/5
#> frequency = 5 observations per 1 week
#> x Slice2: preprocessor 1/1, model 4/5:
#>   Error in `modeltime::new_modeltime_bridge()`:
#>   ! 'data' does not have 4 columns
#>   
#>   'data' should be a data frame (or tibble) containing 4 columns:
#>    1. date column (with name that matches input data)
#>    2. .actual (these are the original values your model trains from)
#>    3. .fitted (these are your model's in-sample training results)
#>    4. .residuals (these are your model's in-sample errors)
#> i Slice2: preprocessor 1/1
#> ✓ Slice2: preprocessor 1/1
#> i Slice2: preprocessor 1/1, model 5/5
#> frequency = 5 observations per 1 week
#> ✓ Slice2: preprocessor 1/1, model 5/5
#> i Slice2: preprocessor 1/1, model 5/5 (predictions)
#> i Slice3: preprocessor 1/1
#> ✓ Slice3: preprocessor 1/1
#> i Slice3: preprocessor 1/1, model 1/5
#> frequency = 5 observations per 1 week
#> ✓ Slice3: preprocessor 1/1, model 1/5
#> i Slice3: preprocessor 1/1, model 1/5 (predictions)
#> i Slice3: preprocessor 1/1
#> ✓ Slice3: preprocessor 1/1
#> i Slice3: preprocessor 1/1, model 2/5
#> frequency = 5 observations per 1 week
#> ✓ Slice3: preprocessor 1/1, model 2/5
#> i Slice3: preprocessor 1/1, model 2/5 (predictions)
#> i Slice3: preprocessor 1/1
#> ✓ Slice3: preprocessor 1/1
#> i Slice3: preprocessor 1/1, model 3/5
#> frequency = 5 observations per 1 week
#> ✓ Slice3: preprocessor 1/1, model 3/5
#> i Slice3: preprocessor 1/1, model 3/5 (predictions)
#> i Slice3: preprocessor 1/1
#> ✓ Slice3: preprocessor 1/1
#> i Slice3: preprocessor 1/1, model 4/5
#> frequency = 5 observations per 1 week
#> ✓ Slice3: preprocessor 1/1, model 4/5
#> i Slice3: preprocessor 1/1, model 4/5 (predictions)
#> i Slice3: preprocessor 1/1
#> ✓ Slice3: preprocessor 1/1
#> i Slice3: preprocessor 1/1, model 5/5
#> frequency = 5 observations per 1 week
#> ✓ Slice3: preprocessor 1/1, model 5/5
#> i Slice3: preprocessor 1/1, model 5/5 (predictions)

tune_results %>% show_best(metric = "rmse")
#> # A tibble: 5 × 8
#>   arch_order garch_order .metric .estimator   mean     n  std_err .config       
#>        <int>       <int> <chr>   <chr>       <dbl> <int>    <dbl> <chr>         
#> 1          1           0 rmse    standard   0.0195     1 NA       Preprocessor1…
#> 2          0           2 rmse    standard   0.0199     3  0.00194 Preprocessor1…
#> 3          2           3 rmse    standard   0.0212     3  0.00169 Preprocessor1…
#> 4          3           1 rmse    standard   0.0212     3  0.00168 Preprocessor1…
#> 5          2           1 rmse    standard   0.0212     3  0.00167 Preprocessor1…

sessionInfo()
#> R version 4.2.1 (2022-06-23)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Debian GNU/Linux 11 (bullseye)
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
#>  [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
#>  [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] parallel  stats     graphics  grDevices utils     datasets  methods  
#> [8] base     
#> 
#> other attached packages:
#>  [1] yardstick_1.0.0    workflowsets_1.0.0 workflows_1.0.0    tune_1.0.0        
#>  [5] rsample_1.0.0      recipes_1.0.1      modeldata_1.0.0    infer_1.0.2       
#>  [9] dials_1.0.0        scales_1.2.0       broom_1.0.0        tidymodels_1.0.0  
#> [13] forcats_0.5.1      stringr_1.4.0      dplyr_1.0.9        purrr_0.3.4       
#> [17] readr_2.1.2        tidyr_1.2.0        tibble_3.1.8       ggplot2_3.3.6     
#> [21] tidyverse_1.3.1    timetk_2.8.1       garchmodels_0.1.1  rmgarch_1.3-9     
#> [25] rugarch_1.4-8      parsnip_1.0.0     
#> 
#> loaded via a namespace (and not attached):
#>   [1] colorspace_2.0-3            ellipsis_0.3.2             
#>   [3] class_7.3-20                mclust_5.4.10              
#>   [5] snakecase_0.11.0            corpcor_1.6.10             
#>   [7] fs_1.5.2                    listenv_0.8.0              
#>   [9] furrr_0.3.0                 spd_2.0-1                  
#>  [11] prodlim_2019.11.13          fansi_1.0.3                
#>  [13] mvtnorm_1.1-3               lubridate_1.8.0            
#>  [15] xml2_1.3.3                  codetools_0.2-18           
#>  [17] splines_4.2.1               R.methodsS3_1.8.2          
#>  [19] knitr_1.39                  jsonlite_1.8.0             
#>  [21] Rmpfr_0.8-9                 dbplyr_2.2.0               
#>  [23] R.oo_1.25.0                 httr_1.4.3                 
#>  [25] compiler_4.2.1              backports_1.4.1            
#>  [27] assertthat_0.2.1            Matrix_1.4-1               
#>  [29] fastmap_1.1.0               cli_3.3.0                  
#>  [31] htmltools_0.5.2             tools_4.2.1                
#>  [33] gmp_0.6-6                   gtable_0.3.0               
#>  [35] glue_1.6.2                  Rcpp_1.0.9                 
#>  [37] cellranger_1.1.0            styler_1.7.0               
#>  [39] DiceDesign_1.9              vctrs_0.4.1                
#>  [41] modeltime_1.2.2             iterators_1.0.14           
#>  [43] timeDate_3043.102           gower_1.0.0                
#>  [45] xfun_0.31                   globals_0.16.0             
#>  [47] GeneralizedHyperbolic_0.8-4 rvest_1.0.2                
#>  [49] Bessel_0.6-0                lifecycle_1.0.1            
#>  [51] future_1.26.1               MASS_7.3-57                
#>  [53] zoo_1.8-10                  ipred_0.9-13               
#>  [55] hms_1.1.1                   DistributionUtils_0.6-0    
#>  [57] yaml_2.3.5                  StanHeaders_2.21.0-7       
#>  [59] SkewHyperbolic_0.4-0        rpart_4.1.16               
#>  [61] stringi_1.7.8               highr_0.9                  
#>  [63] pcaPP_2.0-2                 foreach_1.5.2              
#>  [65] lhs_1.1.5                   hardhat_1.2.0              
#>  [67] lava_1.6.10                 truncnorm_1.0-8            
#>  [69] rlang_1.0.4                 pkgconfig_2.0.3            
#>  [71] Rsolnp_1.16                 pracma_2.3.8               
#>  [73] evaluate_0.15               lattice_0.20-45            
#>  [75] ks_1.13.5                   bit_4.0.4                  
#>  [77] tidyselect_1.1.2            parallelly_1.32.0          
#>  [79] magrittr_2.0.3              R6_2.5.1                   
#>  [81] generics_0.1.3              DBI_1.1.3                  
#>  [83] pillar_1.8.0                haven_2.5.0                
#>  [85] withr_2.5.0                 xts_0.12.1                 
#>  [87] survival_3.3-1              nnet_7.3-17                
#>  [89] future.apply_1.9.0          janitor_2.1.0              
#>  [91] modelr_0.1.8                crayon_1.5.1               
#>  [93] KernSmooth_2.23-20          utf8_1.2.2                 
#>  [95] tzdb_0.3.0                  rmarkdown_2.14             
#>  [97] readxl_1.4.0                grid_4.2.1                 
#>  [99] reprex_2.0.1                digest_0.6.29              
#> [101] R.cache_0.16.0              ff_4.0.7                   
#> [103] numDeriv_2016.8-1.1         R.utils_2.12.0             
#> [105] RcppParallel_5.1.5          munsell_0.5.0              
#> [107] GPfit_1.0-8

Created on 2022-08-11 by the reprex package (v2.0.1)

Standard output and standard error
-- nothing to show --
@larry77
Copy link
Author

larry77 commented Aug 21, 2022

Hello, any reaction on this?

@larry77
Copy link
Author

larry77 commented Sep 30, 2022

?

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