Giter VIP home page Giter VIP logo

garchmodels's Introduction

Hi! 👋🏼 I'm Alberto Almuiña!

📈 Time Series Lover / Data Scientist 📊

Some facts about myself:

me <- list(
  name = "Almuiña",
  first_name = "Alberto",
  occupation = "Data Scientist",
  employer = "ABANCA",
  favorite_programming_language = "R",
  my_r_packages = c("boostime", "bayesmodels", "garchmodels", "neuralprophet", 
                    "DSpoty", "shinyrecipes", "ROMDB", "rgenius")
)

📌 You can check my Blog where I talk about my experiences and the packages I develop 📖

Connect with me:

alberto-almuiña alberto-almuiña-blog

Languages and Tools:

azure python R scikit_learn tidyverse tidymodels reticulate git

Alberto Almuiña

garchmodels's People

Contributors

albertoalmuinha avatar emilhvitfeldt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

garchmodels's Issues

Problems in validating the arguments.

During the tests that I did on my computer (following the tutorial provided in the repository), I had some problems, below I will put the code (and the result printed by the terminal after the execution of each block of code):

install.packages("garchmodels")
install.packages("timetk")
install.packages("tidymodels")
install.packages("tidyverse")
install.packages("devtools")
devtools::install_github("AlbertoAlmuinha/garchmodels")

library(garchmodels)
library(timetk)
library(tidymodels)
library(tidyverse)

-------------------------------------------------------------------------

rIBM

exit :

#> # A tibble: 3,523 x 2
#> date daily_returns
#>
#> 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

-------------------------------------------------------------------------

rIBM_extended <- rIBM %>%
future_frame(.length_out = 3, .bind_data = TRUE)

exit : .date_var is missing. Using: date

-------------------------------------------------------------------------

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

exit :

-------------------------------------------------------------------------

model_fit_garch <-garchmodels::garch_reg(mode = "regression",
arch_order = 1,
garch_order = 1,
ma_order = 0,
ar_order = 0) %>%
set_engine("rugarch", mean.model = list(include.mean = FALSE)) %>%
fit(daily_returns ~ date, data = rIBM_train)

exit : Error in loadNamespace(name) : there is no package called 'modeltime' Timing stopped at: 0.01 0 0.01

-------------------------------------------------------------------------

plot(model_fit_garch$fit$models$model_1, which = 2)
#>
#> please wait...calculating quantiles...

exit : Error in h(simpleError(msg, call)) : error in the evaluation of the argument 'x' in the selection of the method for the function 'plot': 'object' model_fit_garch 'not found'

-------------------------------------------------------------------------

predict(model_fit_garch, rIBM_future)

exit : Error in predict(model_fit_garch, rIBM_future) : 'object' model_fit_garch 'not found'

model_fit_garch <-garchmodels::garch_reg(mode = "regression",
arch_order = 1,
garch_order = 1,
ma_order = 2,
ar_order = 2) %>%
set_engine("rugarch") %>%
fit(daily_returns ~ date, data = rIBM_train)

exit : Error in loadNamespace(name) : there is no package called 'modeltime' Timing stopped at: 0 0 0

-------------------------------------------------------------------------

plot(model_fit_garch$fit$models$model_1, which = 2)

exit : Error in h(simpleError(msg, call)) : error in the evaluation of the argument 'x' in the selection of the method for the function 'plot': 'object' model_fit_garch 'not found'

-------------------------------------------------------------------------

plot(model_fit_garch$fit$models$model_1, which = 3)

Error in h(simpleError(msg, call)) : error in the evaluation of the argument 'x' in the selection of the method for the function 'plot': 'object' model_fit_garch 'not found'

-------------------------------------------------------------------------

predict(model_fit_garch, rIBM_future)

exit : Error in predict(model_fit_garch, rIBM_future) : object 'model_fit_garch' not found

-------------------------------------------------------------------------

there is an instruction or library that was not in the tutorial ? : Getting Started with Garchmodels
(I would like to apologize for my issue being too long, I don't know any other way to communicate the other that I found. 👋)

Garchmodels Installation Fails

Hello,
I would like to know if this package is still actively supported.
I wanted to give it a go since it is very interesting for me the possibility of automatically tuning a Garch model.
However, the package is no longer on CRAN and when I try to install it from github on my platform (Debian linux) here is what happens

> devtools::install_github("AlbertoAlmuinha/garchmodels")
Downloading GitHub repo AlbertoAlmuinha/garchmodels@HEAD
   checking for file ‘/tmp/Rtmp6WO2o5/remotes27e32767473a3/AlbertoAlmuinha-garch✔  checking for file ‘/tmp/Rtmp6WO2o5/remotes27e32767473a3/AlbertoAlmuinha-garchmodels-2385a06/DESCRIPTION’
─  preparing ‘garchmodels’:
✔  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘garchmodels_0.1.1.tar.gz’
   
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
* installing *source* package ‘garchmodels’ ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘garchmodels’:
 .onLoad failed in loadNamespace() for 'garchmodels', details:
  call: check_mode_for_new_engine(model, eng, mode)
  error: 'regression' is not a known mode for model `garch_reg()`.
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/usr/local/lib/R/site-library/garchmodels’
Warning message:
In i.p(...) :
  installation of package ‘/tmp/Rtmp6WO2o5/file27e322c67e19e/garchmodels_0.1.1.tar.gz’ had non-zero exit status


> 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] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9        compiler_4.2.1    later_1.3.0       urlchecker_1.0.1 
 [5] prettyunits_1.1.1 profvis_0.3.7     remotes_2.4.2     tools_4.2.1      
 [9] digest_0.6.29     pkgbuild_1.3.1    pkgload_1.3.0     memoise_2.0.1    
[13] lifecycle_1.0.1   rlang_1.0.4       shiny_1.7.1       cli_3.3.0        
[17] curl_4.3.2        fastmap_1.1.0     withr_2.5.0       stringr_1.4.0    
[21] fs_1.5.2          htmlwidgets_1.5.4 devtools_2.4.4    rprojroot_2.0.3  
[25] glue_1.6.2        R6_2.5.1          processx_3.6.1    sessioninfo_1.2.2
[29] callr_3.7.0       purrr_0.3.4       magrittr_2.0.3    ps_1.7.1         
[33] promises_1.2.0.1  ellipsis_0.3.2    htmltools_0.5.2   usethis_2.1.6    
[37] mime_0.12         xtable_1.8-4      httpuv_1.6.5      stringi_1.7.8    
[41] miniUI_0.1.1.1    cachem_1.0.6      crayon_1.5.1     
> 


Any idea about how I can fix this?

Thanks a lot.

Warnings/Errors when Running the Examples to Tune the Parameters

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 --

dials parameters

Create dials parameters for arma order and garch order for univariate algorithm.

GARCH Models in R with Dummy variables

Hi everyone

I got the time series Problem.

I want to use multivar. GARCH model with binary predictor, where binary (dummy) variable being calendar feature like January (1 for Yes 0 for no)

Problem: I cannot fit calendar features as dummy variable.
Could someone suggest any useful packages with code example.

I tried to do it with garchmodells package.

Below is my code and error message:

DAX_rugarch_01_month <-
garch_multivariate_reg(
mode = "regression", type = "ugarchspec"
) %>%
set_engine("rugarch", specs= list(
spec1 = list(mean.model = list(armaOrder = c(1,0))),
spec2 = list(mean.model = list(armaOrder = c(1,0))),
spec3 = list(mean.model = list(armaOrder = c(1,0)))
)) %>%
fit(Return~ Date + January, data = DAX_train_January)

Error:
multifit GARCH-->error: speclist length not equal to data length

Somethiny is off with my specs at set_engines? The number of dimensions is 3, so I got spec1, spec2, spec3.

Would appreciate any help!

Error: package or namespace load failed for ‘garchmodels’

Already tried to reinstall R, Rstudio and all packages but still getting this error...

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
Error: package or namespace load failed for ‘garchmodels’:
 .onLoad failed in loadNamespace() for 'garchmodels', details:
  call: check_model_doesnt_exist(model)
  error: Model `garch_reg` already exists

Multivariate Engine Unification

Try to unificate multivariate engines because they work very similar but changing functions. Think about introduce something like a "type" parameter to select the type of multivariate algorithm.

Garchmodels Roadmap

Garchmodels Project Roadmap

  • Create Package Structure
  • Develop Univariate Algorithm from rugarch package
  • Develop Multivariate Algorithm from rugarch package
  • Develop Multivariate Algorithms from rmgarch package
  • Create tests
  • Automate Tests with GitHub Actions
  • Make README
  • Make Getting Started Vignette
  • Pkgdown Documentation
  • Send to CRAN

Future Work

  • DIals Parameters for Tuning in Univariate Algorithms #2
  • Engine Unification in Multivariate Algorithms #3
  • Support for Tuning Multivariate Models #4

Models Roadmap

  • Markov-Switching Models through MSGARGH 📦

  • Log Garch Models through the lgarch 📦

Support for Tuning Multivariate Models

Add support for the rugarch engine to be able to tune and think if something similar could be done with some other engine (it would be complicated because it would imply changing the prediction output).

loadNamespace() Error

if(!require(pacman)) install.packages("pacman")
pacman::p_load(
  "tidymodels",
  "modeltime",
  "dplyr",
  "lubridate",
  "timetk",
  "odbc",
  "DBI",
  "janitor",
  "tidyquant",
  "modeltime.ensemble",
  "modeltime.resample",
  "modeltime.h2o"
)
library(bayesmodels)
library(garchmodels)

Produces the following:

if(!require(pacman)) install.packages("pacman")
Loading required package: pacman
> pacman::p_load(
+   "tidymodels",
+   "modeltime",
+   "dplyr",
+   "lubridate",
+   "timetk",
+   "odbc",
+   "DBI",
+   "janitor",
+   "tidyquant",
+   "modeltime.ensemble",
+   "modeltime.resample",
+   "modeltime.h2o"
Registered S3 method overwritten by 'quantmod':
  method            from
  as.zoo.data.frame zoo 
Registered S3 methods overwritten by 'bayesforecast':
  method      from    
  autoplot.ts forecast
  forecast.ts forecast
  fortify.ts  forecast
  print.garch tseries 
+ )
> library(bayesmodels)
Loading required package: bayesforecast

Attaching package:bayesforecastThe following objects are masked frompackage:base:

    beta, gamma

Loading required package: bsts
Loading required package: BoomSpikeSlab
Loading required package: Boom
Loading required package: MASS

Attaching package:MASSThe following object is masked frompackage:dplyr:

    select


Attaching package:BoomThe following object is masked frompackage:stats:

    rWishart


Attaching package:BoomSpikeSlabThe following object is masked frompackage:stats:

    knots


Attaching package:bstsThe following object is masked frompackage:BoomSpikeSlab:

    SuggestBurn


Attaching package:bayesmodelsThe following objects are masked frompackage:modeltime:

    non_seasonal_ar, non_seasonal_differences, non_seasonal_ma, seasonal_ar,
    seasonal_differences, seasonal_ma

The following object is masked frompackage:dials:

    tree_depth

Warning messages:
1: packagebayesmodelswas built under R version 4.0.5 
2: packagebayesforecastwas built under R version 4.0.5 
3: packagebstswas built under R version 4.0.5 
4: packageBoomSpikeSlabwas built under R version 4.0.5 
5: packageBoomwas built under R version 4.0.5 
6: packageMASSwas built under R version 4.0.5 
> library(garchmodels)
Loading required package: rugarch
Loading required package: parallel

Attaching package:rugarchThe following object is masked frompackage:bayesforecast:

    report

The following object is masked frompackage:purrr:

    reduce

The following object is masked frompackage:stats:

    sigma

Loading required package: rmgarch

Attaching package:rmgarchThe following objects are masked frompackage:xts:

    first, last

The following objects are masked frompackage:dplyr:

    first, last

Registered S3 methods overwritten by 'garchmodels':
  method              from       
  print.garch_reg     bayesmodels
  translate.garch_reg bayesmodels
  update.garch_reg    bayesmodels
Error: package or namespace load failed forgarchmodels:
 .onLoad failed in loadNamespace() for 'garchmodels', details:
  call: NULL
  error: Model `garch_reg` already exists
In addition: Warning messages:
1: packagegarchmodelswas built under R version 4.0.5 
2: packagerugarchwas built under R version 4.0.5 
3: packagermgarchwas built under R version 4.0.5 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.