-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: matjags #214
Comments
Hi. So basically I've stopped using Matlab and have switched to Python and Julia. So I've stopped maintaining this package. It's also because it's vastly more complicated that it needs to be. Having said that, we may still be able to get something sorted. The core thing is the JAGS model and the data. Not sure if you are familiar, but you can now run JAGS models in JASP. I've been meaning to try this out, so your message might be the catalyst. If you are interested, then I'd be happy to message back and forth to get something working using JAGS within JASP. Let me know. |
Hi Ben,
Thanks ever so much for getting back to me.
It is a shame that you no longer maintain the Matlab package. Is there a similar version I could try in python? I have python and have done some very basic scripting using it, however I am still new to the language.
If you were happy to direct me on how to run the JAGS model and data through JASP (I am unfamiliar with this) I’d be very grateful.
I look forward to hearing from you.
Best,
George
…Sent from my iPhone
On 15 Apr 2021, at 19:34, Benjamin T. Vincent ***@***.***> wrote:
Hi. So basically I've stopped using Matlab and have switched to Python and Julia. So I've stopped maintaining this package. It's also because it's vastly more complicated that it needs to be.
Having said that, we may still be able to get something sorted. The core thing is the JAGS model and the data. Not sure if you are familiar, but you can now run JAGS models in JASP. I've been meaning to try this out, so your message might be the catalyst.
If you are interested, then I'd be happy to message back and forth to get something working using JAGS within JASP. Let me know.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
If you wanted to give it a go in Python, then I've got some example scripts (in Jypyter notebook form) which I've used for previous papers. I'm actually thinking that way simpler analysis scripts are the way to go - as opposed to toolboxes. It keeps the code simple and entirely transparent. Toolboxes get complex and opaque, perhaps overcoming the benefits of a simple API to ask for results. Examples of Python based analyses for some papers are:
If you want to try the JASP+JAGS approach, I'd be happy to do that. If you are able to send me the data (just email me at my university of Dundee address) then I could work on that. If you can't (or don't feel like it would be appropriate) then just let me know:
Regardless of Python vs JAGS/JASP, you'd need your data in the following form:
|
Hi Ben,
Sorry about the late response, I was awaiting a reply from a member of the department regarding whether it would be a appropriate for me to recieve help in analysis from someone external to the university. As this is for my final dissertation I am taking extra precaution as plagarism and collusion are taken very seriously for this assignment. Unfortunately I do not think it would be appropraite for me to hand the analysis over to you directly for these reasons. Any sort of guidance would be hugely appreciated however.
I am interested in both k and the magnitude effect model, however as the DD data will be the DV in my regression model when it comes to analysis, realistically I will only be able to use the one (most likely k).
All of my data is already in a series of .csv files in the format you show in one of your videos introducing the matlab script. I also have a compiled file which was given as an output of the original script. I have also manually calculated all of the k values for each question in my discounting task if that helps.
I look forward to hearing from you. Again thank you so much for taking the time to help me!
Best,George
On Friday, April 16, 2021, 12:24:37 PM GMT+1, Benjamin T. Vincent ***@***.***> wrote:
If you wanted to give it a go in Python, then I've got some example scripts (in Jypyter notebook form) which I've used for previous papers. I'm actually thinking that way simpler analysis scripts are the way to go - as opposed to toolboxes. It keeps the code simple and entirely transparent. Toolboxes get complex and opaque, perhaps overcoming the benefits of a simple API to ask for results. Examples of Python based analyses for some papers are:
- https://github.com/drbenvincent/Xu-GonzalezVallejo-Vincent
- https://github.com/drbenvincent/skrynka-vincent
- https://github.com/drbenvincent/Veillard-Vincent/blob/master/data/mcq_wcq_scoring/SCORING.ipynb
If you want to try the JASP+JAGS approach, I'd be happy to do that. If you are able to send me the data (just email me at my university of Dundee address) then I could work on that. If you can't (or don't feel like it would be appropriate) then just let me know:
- are you interested in log(k) scores for people, or are you interested in the magnitude effect model which gives you m and c parameters?
Regardless of Python vs JAGS/JASP, you'd need your data in the following form:
- all in one .csv file
- each row is an experimental trial
- column for participant number
- columns for discounting: reward sizes A, B, and corresponding delays DA, DB, and response R (0 for immediate choice A, 1 for delayed choice B).
- it doesn't matter if there are additional columns for things like conditions or other participant measures. And in fact that could be useful for doing more complex extended models.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
I understand about the data, no problem. I've given this a go with a basic hyperbolic discounting model that gives you log(k) discount rates. If you've got your data sorted, then these steps should be simple, but let me know how you get on...
NOTE: The JAGS model assumes that the sooner reward is immediate (ie. I obviously don't know what your research question is about - but I'd suggest focussing on log discount rates ( If you use this, can you cite this paper?
Just let me know if you run into issues. |
Hi Ben,
Thank you very much for getting back to me.
This level of help is amazing. I'm going to have a go at running it today. I will be sure to let you know if I run into any issues.
I will certainly use the citation to your paper in my project.
Thanks again.
Best,George
On Wednesday, April 21, 2021, 07:51:34 PM GMT+1, Benjamin T. Vincent ***@***.***> wrote:
I understand about the data, no problem. I've given this a go with a basic hyperbolic discounting model that gives you log(k) discount rates. If you've got your data sorted, then these steps should be simple, but let me know how you get on...
- Download latest version of JASP (I have 0.14.1)
- Open JASP. Click the big "+" icon in the top right and tick the JAGS box.
- Import your data with Open > Computer > Browse and point it towards your .csv file. Mine looks like this:
- Create a JAGS analysis block by clicking on the JAGS icon in the top ribbon of JASP.
- Enter the following JAGS model code.
model{
# set up priors for each participant
for (p in 1:max(id))
{
logk[p] ~ dnorm(log(1/50), 1/(2.5^2))
alpha[p] ~ dexp(0.01)
epsilon[p] ~ dbeta(1.1, 10.9) T(,0.5)
}
# loop over trials (rows in the dataset)
for (t in 1:length(R))
{
VB[t] <- B[t] / (1+(exp(logk[id[t]])*DB[t]))
P[t] <- epsilon[id[t]] + (1-2*epsilon[id[t]]) * phi( (VB[t]-A[t]) / alpha[id[t]] )
R[t] ~ dbern(P[t])
}
}
- Press command-enter (for Mac) or whatever the PC equivalent it. This might run or it might ask for what variables you want to plot. The main one of interest is logk. I have something that looks like this:
- After selecting those variables, you might need to command-enter again to make it work. With the default parameters it didn't take long on my laptop at all, but that was just with a quick demo file of 4 participants. If there are errors, make sure that the column headers which define the variables match up with what is in the JAGS model text. For example I have my participant column labelled as id (in lowercase)
- In the Plots tab in the JAGS analysis, click "Density" and it will show you the posterior distributions over the log discount rates, or whatever variables you have asked it to display.
- You also get a table of results. The main things of interest will be the logk values. There doesn't seem to be a way to export this into a file, so you might have to manually enter the posterior mean values of logk into a file for final analysis or further statistical tests you want to do. Obviously the logk[1], ..., logk[N] will correspond to the id, so make sure you don't mix up the order of participants if you are doing further stats on these scored log discount rates. The results for my test file of 4 participants looks like this.
NOTE: The JAGS model assumes that the sooner reward is immediate (ie. DA=0). If that's not the case then let me know, but if you've used the Kirby set of questions then it should be.
I obviously don't know what your research question is about - but I'd suggest focussing on log discount rates (logk) to have a single measure of discounting for each person. But if your research questions require knowing about the magnitude effect, just let me know and I can adapt the JAGS model for that.
If you use this, can you cite this paper?
Vincent, B. T. (2016). Hierarchical Bayesian estimation and hypothesis testing for delay discounting tasks. Behavior Research Methods. 48(4), 1608-1620.
Just let me know if you run into issues.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
For anyone else coming across this in the future, I have developed clearer and more extensive instructions here: https://github.com/drbenvincent/jasp_discounting |
Hi, I'm not sure whether this is still an active thread. I am currently trying to use your script to analyse some delay discounting data but I cant for the life of me seem to get it to work. I have both git and JAGS installed, the three dependencies installed and located in the MATLAB folder. I will leave you with the error message, if you can help me at all I'd be very appreciative as this is for my final year disseration study! :)
Error:File: matjags.m Line: 257 Column: 67
Identifier 'durationSeconds' is not a function or a shared variable. To share 'durationSeconds' with nested function,
initialize it in the current scope. For more information, see Sharing Variables Between Parent and Nested Functions.
Error in sampleWithMatjags (line 18)
[samples, stats] = matjags(...
Error in Model/conductInference (line 116)
obj.coda = samplerFunction(...
Error in ModelHierarchicalME (line 16)
obj = obj.conductInference();
Error in run_me (line 107)
model = ModelHierarchicalME(...
The text was updated successfully, but these errors were encountered: