CCS-Lab / hBayesDM

Hierarchical Bayesian modeling of RLDM tasks, using R & Python
https://ccs-lab.github.io/hBayesDM
GNU General Public License v3.0
223 stars 113 forks source link

DDM model not sampling #42

Closed fusaroli closed 6 years ago

fusaroli commented 6 years ago

I'm trying to run the drift diffusion model on the example data:

m <- choiceRT_ddm("example", niter = 2000, nwarmup = 1000, nchain = 2, ncore = 2)

This does not work and gives the following error:

> [1] "Error in sampler$call_sampler(args_list[[i]]) : "
> [2] "  c++ exception (unknown reason)"                
> error occurred during calling the sampler; sampling not done

All other models in hBayesDM run (on the "example" data). Occasionally one of the chains in choiceRT_lba run on the "example" data gives the same issue. Reinstalling hBayesDM, restarting R and the computer does not help.

I am using hBayesDM 0.6, rstan 2.17.3, R 3.5.1, RStudio 1.1.456, on a Mac OS 10.13.6.

Full output of the function below

> Model name =  choiceRT_ddm 
> Data file  =  /Library/Frameworks/R.framework/Versions/3.5/Resources/library/hBayesDM/extdata/choiceRT_exampleData.txt 
> 
> Details:
>  n of chains                   =  2 
>  n of cores used               =  2 
>  n of MCMC samples (per chain) =  2000 
>  n of burn-in samples          =  1000 
>  n of subjects                 =  5 
>  n of (max) trials of this subject =  1000 
> 
> ***********************************
> **  Loading a precompiled model  **
> ***********************************
> trying deprecated constructor; please alert package maintainer
> starting worker pid=1573 on localhost:11760 at 15:57:42.969
> starting worker pid=1583 on localhost:11760 at 15:57:43.148
> trying deprecated constructor; please alert package maintainer
> 
> SAMPLING FOR MODEL 'choiceRT_ddm' NOW (CHAIN 1).
> 
> Gradient evaluation took 0.011388 seconds
> 1000 transitions using 10 leapfrog steps per transition would take 113.88 seconds.
> Adjust your expectations accordingly!
> 
> 
> [1] "Error in sampler$call_sampler(args_list[[i]]) : "
> [2] "  c++ exception (unknown reason)"                
> error occurred during calling the sampler; sampling not done
> trying deprecated constructor; please alert package maintainer
> 
> SAMPLING FOR MODEL 'choiceRT_ddm' NOW (CHAIN 2).
> 
> Gradient evaluation took 0.014098 seconds
> 1000 transitions using 10 leapfrog steps per transition would take 140.98 seconds.
> Adjust your expectations accordingly!
> 
> 
> [1] "Error in sampler$call_sampler(args_list[[i]]) : "
> [2] "  c++ exception (unknown reason)"                
> error occurred during calling the sampler; sampling not done
> here are whatever error messages were returned
> [[1]]
> Stan model 'choiceRT_ddm' does not contain samples.
> 
> [[2]]
> Stan model 'choiceRT_ddm' does not contain samples.
> 
> Stan model 'choiceRT_ddm' does not contain samples.
> 
> ************************************
> **** Model fitting is complete! ****
> ************************************
> There were 21 warnings (use warnings() to see them)

Warnings are:

> Warning messages:
> 1: In .local(object, ...) :
>   some chains had errors; consider specifying chains = 1 to debug
> 2: In mean.default(alpha[, i]) : argument is not numeric or logical: returning NA
> 3: In mean.default(beta[, i]) : argument is not numeric or logical: returning NA
> 4: In mean.default(delta[, i]) : argument is not numeric or logical: returning NA
> 5: In mean.default(tau[, i]) : argument is not numeric or logical: returning NA
> 6: In mean.default(alpha[, i]) : argument is not numeric or logical: returning NA
> 7: In mean.default(beta[, i]) : argument is not numeric or logical: returning NA
> 8: In mean.default(delta[, i]) : argument is not numeric or logical: returning NA
> 9: In mean.default(tau[, i]) : argument is not numeric or logical: returning NA
> 10: In mean.default(alpha[, i]) :
>   argument is not numeric or logical: returning NA
> 11: In mean.default(beta[, i]) : argument is not numeric or logical: returning NA
> 12: In mean.default(delta[, i]) :
>   argument is not numeric or logical: returning NA
> 13: In mean.default(tau[, i]) : argument is not numeric or logical: returning NA
> 14: In mean.default(alpha[, i]) :
>   argument is not numeric or logical: returning NA
> 15: In mean.default(beta[, i]) : argument is not numeric or logical: returning NA
> 16: In mean.default(delta[, i]) :
>   argument is not numeric or logical: returning NA
> 17: In mean.default(tau[, i]) : argument is not numeric or logical: returning NA
> 18: In mean.default(alpha[, i]) :
>   argument is not numeric or logical: returning NA
> 19: In mean.default(beta[, i]) : argument is not numeric or logical: returning NA
> 20: In mean.default(delta[, i]) :
>   argument is not numeric or logical: returning NA
> 21: In mean.default(tau[, i]) : argument is not numeric or logical: returning NA
fusaroli commented 6 years ago

Update: if I do not use the pre-compiled versions of the models the sampler starts (200 iterations so far). So the problem is most likely with the compiled model.

youngahn commented 6 years ago

Super strange. I'm using exactly the same settings and it runs just fine. Another member in my lab tested this in another Mac computer, and he had no issues, either.

fusaroli commented 6 years ago

I reproduced it on my stationary iMac, as well, and solved it again compiling the models. Weird. I'm closing the issue, since there is a solution.