ellisp / forecastHybrid

Convenient functions for ensemble forecasts in R combining approaches from the {forecast} package
GNU General Public License v3.0
79 stars 23 forks source link

Error with cvts example #79

Closed pascaloettli closed 6 years ago

pascaloettli commented 7 years ago

Trying to replicate an example from cvts help page, an error occurs:

library(forecastHybrid)

# We can also use custom functions, for example fcast() from the "GMDH" package
library(GMDH)
GMDHForecast <- function(x, h){fcast(x, f.number = h)}
gmdhcv <- cvts(AirPassengers, FCFUN = GMDHForecast)

Error in { : task 1 failed - "could not find function "fcast""

sessionInfo()

R version 3.4.1 (2017-06-30) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 16.04.3 LTS

Matrix products: default BLAS/LAPACK: /usr/lib/libopenblasp-r0.2.18.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] stats graphics grDevices utils datasets methods base

other attached packages: [1] GMDH_1.6 forecastHybrid_1.1.9 forecast_8.1

loaded via a namespace (and not attached): [1] Rcpp_0.12.12 magrittr_1.5 MASS_7.3-47 munsell_0.4.3
[5] doParallel_1.0.10 colorspace_1.3-2 lattice_0.20-35 rlang_0.1.2
[9] quadprog_1.5-5 foreach_1.4.3 TTR_0.23-2 plyr_1.8.4
[13] xts_0.10-0 nnet_7.3-12 parallel_3.4.1 quantmod_0.4-10
[17] grid_3.4.1 timeDate_3012.100 gtable_0.2.0 iterators_1.0.8
[21] tseries_0.10-42 lazyeval_0.2.0 lmtest_0.9-35 tibble_1.3.4
[25] ggplot2_2.2.1 codetools_0.2-15 curl_2.8.1 fracdiff_1.4-2
[29] compiler_3.4.1 scales_0.4.1 zoo_1.8-0

dashaub commented 7 years ago

Hmm, this one might be a little tricky to fix elegantly. It looks like this problem surfaced after we implemented parallelization on the the cvts() function since the parallel runners need to be sent all of the packages that are needed for a fit and forecast. The easiest fix to this would be to add an argument to the cvts() function where the user passes in a vector of strings of all of the packages that are needed. That's a little clunky, so I'll see if there is any way to automatically detect which packages are used in FUN and FCFUN.

dashaub commented 6 years ago

Usage has been updated. There were a few things going on here (one about package imports for parallelization above) and also #81 .