I am working with the BTYD plus code given in https://github.com/mplatzer/BTYDplus/blob/master/R/pareto-nbd-mcmc.r . This code uses the MCMC technique to estimate the Pareto/NBD parameters of the BTYD Model.
So, If you see line 224-228 of the code, it uses the function 'mclapply'- which I found can run only on Linux or MAC. I am working on a windows machine and need to convert this part of the code such that I am able to execute it on a Windows machine as well. So, Can anyone help me with this specific code or could give a general idea of how to use 'mclapply' for windows ?
Use parLapply
:
Sys.info()["sysname"]
# sysname
#"Windows"
library(parallel)
cl <- makeCluster(getOption("cl.cores", 2))
l <- list(1, 2)
system.time(
parLapply(cl, l, function(x) {
Sys.sleep(10)
})
)
#user system elapsed
#0 0 10
stopCluster(cl)
You might want to look into the doRNG package for reproducibility if your tasks include random number generation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With