yxlin / ggdmc

Bayesian Cognitive Modelling
https://yxlin.github.io
19 stars 3 forks source link

Trying to calculate DICs from data of 8 participant #5

Closed ezrp closed 1 year ago

ezrp commented 1 year ago

Hi, Yi-Shen,

Thanks for sharing your package, it has been very useful and I'm learning a lot with it!

I got an error when I tried to reproduce the code of this page: https://rdrr.io/github/yxlin/ggdmc/man/DIC-methods.html

The DIC function runs when is used with one participant, but when I tried to run with all the fit, it didn't work, this is the error:

Error in apply(object$theta, 2, mean) :
dim(X) must have a positive length

This is my session info:

> sessionInfo()
R version 4.2.3 (2023-03-15 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=Spanish_Spain.utf8  LC_CTYPE=Spanish_Spain.utf8   
[3] LC_MONETARY=Spanish_Spain.utf8 LC_NUMERIC=C                  
[5] LC_TIME=Spanish_Spain.utf8    

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

other attached packages:
 [1] ez_4.4-0          DescTools_0.99.48 ggdmc_0.2.6.0    
 [4] ggpubr_0.5.0      rstatix_0.7.1     lubridate_1.9.0  
 [7] timechange_0.1.1  forcats_1.0.0     stringr_1.5.0    
[10] dplyr_1.1.1       purrr_1.0.1       readr_2.1.4      
[13] tidyr_1.3.0       tibble_3.2.1      ggplot2_3.4.2    
[16] tidyverse_2.0.0  

Thanks for any help you can give me.

yxlin commented 1 year ago

Dear ezrp,

The problem might be in the old version of the DIC function. I apologise that I do not have time in the near term to update the software in CRAN, because that may involve more work than just fixing a function. The page you refer to indexes my Github repository, not the 0.2.6 version on CRAN.

A quick solution that may resolve your problem is to (1) remove the 0.2.6 version and then (2) install the 0.2.8.1 version.

remove.packages("ggdmc") devtools::install_github("yxlin/ggdmc")

The reason behind the error message is that there are three different DIC functions in 0.2.8.1 to handle different scenarios. The source code can be viewed in DIC function. They are one function to calculate the DIC using the population level likelihoods (i.e., hyper), one function to calculate the value when the user fits only the data from a participant, and the other one, calculating the values when the user fits a group of participants assuming they are exchangeable.

I hope the answer helps.

Yi-Shin

ezrp commented 1 year ago

Dear Yi-Shin, thanks a lot, it works! I re-installed directly from your github. Thank you very much for your time!

Sorry to bother you again with another question. I have been using ggdmc with some spatial interference tasks data, at the university we tested with 4 different datasets, it works very well. I was wondering if is it possible to build a model with the time-variant feature for the threshold-boundary, i.e., a DDM with collapsing boundaries, using ggdmc?

Thanks again, Renato

yxlin commented 1 year ago

Dear Renato,

Yes.

I have another version of the software, which has built that flexibility. But I use it at the moment only on varying the drift rate and have yet to upload it to GitHub. The basic concept is to vary the size of evidence space based on your boundary assumption when calculating the probability densities at each discrete time step. The knowledge is written in a number of well-known textbooks in stochastic differential equations, used in physics and physical chemistry. For instance, the excellent book, "Stochastic Methods" was written by Crispin Gardiner. The structure of this software is rather loose, i.e., not user-friendly. Do send me an email (yishinlin@pm.me) to set up a Zoom/Team/Others, if you would like to dive into that piece of software and patch it with the varying boundary code.