- Operating System: Windows 10 and Ubuntu 16.04
- CmdStan Version: 2.22.1
- Compiler/Toolkit: Rtools 3.5 (For Windows 10)
- R version: 3.5.3(Windows 10) and 3.6.1 (Ubuntu 16.04)
Problem description :
My code runs perfectly for 1000 instances while using CmdStan but when I run for 10, 000 instances it is stuck both in Windows 10 and Ubuntu 16.04 without throwing any error. Please help I have been stuck at this problem for more than a week now and would be extremely really grateful if the community can please help
Model executable is up to date!
Running MCMC with 2 chain(s) on 2 core(s)...
Running ./tptrain 'id=1' random 'seed=123' data \
'file=/tmp/Rtmpo8bYix/standata-a5af650b9b25.json' output \
'file=/tmp/Rtmpo8bYix/tptrain-202004142313-1-46c5da.csv' 'method=sample' \
'num_samples=100' 'num_warmup=100' 'save_warmup=0' 'algorithm=hmc' \
'engine=nuts' adapt 'engaged=1'
Running ./tptrain 'id=2' random 'seed=124' data \
'file=/tmp/Rtmpo8bYix/standata-a5af650b9b25.json' output \
'file=/tmp/Rtmpo8bYix/tptrain-202004142313-2-46c5da.csv' 'method=sample' \
'num_samples=100' 'num_warmup=100' 'save_warmup=0' 'algorithm=hmc' \
'engine=nuts' adapt 'engaged=1'
Chain 1 Iteration: 1 / 200 [ 0%] (Warmup)
Chain 2 Iteration: 1 / 200 [ 0%] (Warmup)
Code Snippet
stan_program <- file.path(cmdstan_path(), "examples/new/tptrain.stan")
mod <- cmdstan_model(stan_program)
mod$print()
stan_data <- list(N = n, K = length(sense_cols), R = 5, L = 5, D=281, s = data.matrix(tp[,sense_cols]),
location = tp[,c("location")], domain = tp[,c("domain")], rating = tp[,c("rating")])
#
# run MCMC using the 'sample' method
fit_mcmc <- mod$sample(
data = stan_data,
num_samples = 100,
num_warmup = 100,
seed = 123,
num_chains = 2
num_cores = 2
)
Background:
I have been trying to run the Stan code using Rstan in Rstudio for a dataset consisting of 10,000 rows for more than a week now. I got the following error while running the code via terminal in Ubuntu
Error in FUN(X[[i]], ...) :
trying to get slot "mode" from an object (class "try-error") that is not an S4 object
Calls: stan ... sampling -> sampling -> .local -> sapply -> lapply -> FUN
In addition: Warning message:
In parallel::mclapply(1:chains, FUN = callFun, mc.preschedule = FALSE, :
2 function calls resulted in an error
Execution halted
I was getting the following error running the code via Rstudio GUI in Windows 10
Error in unserialize(socklist[[n]]) : error reading from connection
I referred all the forum discussions recommending to delete Makevars file, run for 1 chain, move transformed parameters code to model block, reinstalling rstanarm, no NA in the dataset. But nothing worked I moved to using CmdStanR
please let me know if I need to provide more information