reproducing results in GAS Package

The code does not move forward past the makeCluster step in the supplementary material provided with the package provided in

Downside Risk Evaluation ... The R Journal

Direct link to code:
https://journal.r-project.org/archive/2018/RJ-2018-064/RJ-2018-064.zip

library("GAS")

data("dji30ret", package = "GAS")
dji30ret <- tail(dji30ret, 2500)

GASSpec_N <- UniGASSpec(Dist = "norm", GASPar = list(scale = TRUE))
GASSpec_ST <- UniGASSpec(Dist = "std", GASPar = list(scale = TRUE))
GASSpec_SKST <- UniGASSpec(Dist = "sstd", GASPar = list(scale = TRUE))

library("parallel")
cluster <- makeCluster(2)

I had no trouble. See the sessionInfo() output at end. How does your setup differ?

options(digits = 7, max.print = 40)
library(tictoc)
tic()
library("GAS")
#> 
#> Attaching package: 'GAS'
#> The following object is masked from 'package:stats':
#> 
#>     residuals

data("dji30ret", package = "GAS")
dji30ret <- tail(dji30ret, 2500)

GASSpec_N    <- UniGASSpec(Dist = "norm", GASPar = list(scale = TRUE))
GASSpec_ST   <- UniGASSpec(Dist = "std", GASPar = list(scale = TRUE))
GASSpec_SKST <- UniGASSpec(Dist = "sstd", GASPar = list(scale = TRUE))

library("parallel")
cluster <- makeCluster(2)
toc()
#> 0.36 sec elapsed
sessionInfo()
#> R version 4.2.0 (2022-04-22)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Pop!_OS 22.04 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/local/lib/R/lib/libRblas.so
#> LAPACK: /usr/local/lib/R/lib/libRlapack.so
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] parallel  stats     graphics  grDevices utils     datasets  methods  
#> [8] base     
#> 
#> other attached packages:
#> [1] GAS_0.3.4    tictoc_1.0.1
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.9          pillar_1.8.0        compiler_4.2.0     
#>  [4] highr_0.9           R.methodsS3_1.8.1   R.utils_2.10.1     
#>  [7] tools_4.2.0         xts_0.12.1          digest_0.6.29      
#> [10] evaluate_0.16       lifecycle_1.0.1     tibble_3.1.8       
#> [13] R.cache_0.15.0      lattice_0.20-44     pkgconfig_2.0.3    
#> [16] rlang_1.0.4         reprex_2.0.1        cli_3.3.0          
#> [19] rstudioapi_0.13     yaml_2.3.5          xfun_0.32          
#> [22] fastmap_1.1.0       withr_2.5.0         styler_1.7.0       
#> [25] stringr_1.4.0       knitr_1.39          fs_1.5.2           
#> [28] vctrs_0.4.1         grid_4.2.0          glue_1.6.2         
#> [31] fansi_1.0.3         rmarkdown_2.15      Rsolnp_1.16        
#> [34] purrr_0.3.4         magrittr_2.0.3      MASS_7.3-56        
#> [37] htmltools_0.5.3     cubature_2.0.4.5    numDeriv_2016.8-1.1
#> [40] utf8_1.2.2         
#>  [ reached getOption("max.print") -- omitted 4 entries ]

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

Do you recommend the tictoc package, also our locale's are different for LC_ yours ends utf 8, mine in US 1252?

Thanks for the quick reply, we have quite a few differences see below:

library("GAS")

data("dji30ret", package = "GAS")
dji30ret <- tail(dji30ret, 2500)

GASSpec_N <- UniGASSpec(Dist = "norm", GASPar = list(scale = TRUE))
GASSpec_ST <- UniGASSpec(Dist = "std", GASPar = list(scale = TRUE))
GASSpec_SKST <- UniGASSpec(Dist = "sstd", GASPar = list(scale = TRUE))

library("parallel")
cluster <- makeCluster(2)
sessionInfo()
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] parallel stats graphics grDevices utils datasets
[7] methods base

other attached packages:
[1] GAS_0.3.4

loaded via a namespace (and not attached):
[1] Rcpp_1.0.9 MASS_7.3-58.1
[3] bit_4.0.4 mclust_6.0.0
[5] cubature_2.0.4.5 lattice_0.20-45
[7] pcaPP_2.0-3 Rsolnp_1.16
[9] rmgarch_1.3-9 tools_4.2.2
[11] xts_0.12.2 SkewHyperbolic_0.4-0
[13] GeneralizedHyperbolic_0.8-4 spd_2.0-1
[15] grid_4.2.2 ff_4.0.7
[17] rugarch_1.4-9 KernSmooth_2.23-20
[19] corpcor_1.6.10 remotes_2.4.2
[21] lmtest_0.9-40 numDeriv_2016.8-1.1
[23] gmp_0.6-8 Matrix_1.5-1
[25] DistributionUtils_0.6-0 ks_1.13.5
[27] sandwich_3.0-2 pracma_2.4.2
[29] Rmpfr_0.8-9 compiler_4.2.2
[31] Bessel_0.6-0 truncnorm_1.0-8
[33] mvtnorm_1.1-3 zoo_1.8-11

tictoc was only to show how fast it should run on a mid range laptop. For locale UTF-8 is best for a lot of reasons and might be an issue here if the function is choking on code points outside its own set.

set locales to utf-8 however same issue occured:
Please see below, with that said how long does it take to make a cluster?

library("GAS")

data("dji30ret", package = "GAS")
dji30ret <- tail(dji30ret, 2500)

GASSpec_N <- UniGASSpec(Dist = "norm", GASPar = list(scale = TRUE))
GASSpec_ST <- UniGASSpec(Dist = "std", GASPar = list(scale = TRUE))
GASSpec_SKST <- UniGASSpec(Dist = "sstd", GASPar = list(scale = TRUE))

library("parallel")
cluster <- makeCluster(2)
sessionInfo()
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=en_US.UTF-8 LC_CTYPE=en_US.UTF-8
[3] LC_MONETARY=en_US.UTF-8 LC_NUMERIC=C
[5] LC_TIME=en_US.UTF-8
system code page: 1252

attached base packages:
[1] parallel stats graphics grDevices utils datasets
[7] methods base

other attached packages:
[1] GAS_0.3.4

loaded via a namespace (and not attached):
[1] Rcpp_1.0.9 MASS_7.3-58.1
[3] bit_4.0.4 mclust_6.0.0
[5] cubature_2.0.4.5 lattice_0.20-45
[7] pcaPP_2.0-3 Rsolnp_1.16
[9] rmgarch_1.3-9 tools_4.2.2
[11] xts_0.12.2 SkewHyperbolic_0.4-0
[13] GeneralizedHyperbolic_0.8-4 spd_2.0-1
[15] grid_4.2.2 ff_4.0.7
[17] rugarch_1.4-9 KernSmooth_2.23-20
[19] corpcor_1.6.10 remotes_2.4.2
[21] lmtest_0.9-40 numDeriv_2016.8-1.1
[23] gmp_0.6-8 Matrix_1.5-1
[25] DistributionUtils_0.6-0 ks_1.13.5
[27] sandwich_3.0-2 pracma_2.4.2
[29] Rmpfr_0.8-9 compiler_4.2.2
[31] Bessel_0.6-0 truncnorm_1.0-8
[33] mvtnorm_1.1-3 zoo_1.8-11

library("parallel")
cluster <- makeCluster(2)
#> 0.36 sec elapsed

The time was just 0.36 sec, including loading the library, so it’s pretty quick. What happens in a fresh session with just the snippet above?

The remaining difference in setup is OS, and I’ve been away from Windows since XP, so I can’t help with that.

I can load the library, however makeCluster does not work for me

Looking at help(makeCluster) it works differently depending on the host from which the R session is being run. If it's not on your local machine, that could explain the non-responsiveness. Do you have access to R through a server?

One reported fix this year

parallel::makePSOCKcluster(ncore - 1)

instead of makeClusterr - makeCluster hangs on Windows - parallel package - Stack Overflow). Try that?

I'm using my local machine, I managed to get the same issue they were having using that library

I changed it to parallel::makePSOCKcluster(ncore - 1) in cl and got the same issue

On the link the user presents the question, however it wasn't confirmed as solved by the person who stated the question

I am able to get further in rstudio cloud though,

I meant to put this in the previous post, however I'm not allowed to have more than one image for some reason

changed to parallel::makePSOCKcluster(ncore - 1)

1 Like

Though I got further in Rstudio Cloud

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.