RT plots

215 views
Skip to first unread message

Kitti Ban

unread,
May 19, 2023, 10:34:19 AM5/19/23
to hddm-...@googlegroups.com
Dear all, 

Firstly, thank you so much for all the support provided within this group, I've learnt loads from the solutions offered here.

I've been running neural HDDM regressions such as this one;
m = hddm.HDDMRegressor( data, [ v ~ earlyY + lateY ], include = 'all' ). 

For model comparison, I've run sets of 4 chains to derive Rhat values, mean DICs, and posterior predictive checks. I'd also like to plot the original vs predicted RTs but unfortunately, none of the plotting options seem to work (the figure pops up but doesn't plot anything). Could the issue be that I'm running the HDDM regressions as opposed to the regular HDDMs? Does anyone have any tips for how to create such plots/quantile probability RT plots? 

Any help is much appreciated. 

Thank you,
Kitti Ban
 
Ph.D. candidate 
University of Glasgow

Alexander Fengler

unread,
Jun 6, 2023, 5:11:14 PM6/6/23
to hddm-users
Hi Kitti, 

There is always the manual approach if any of the convenience functions with HDDM don't work:
You can  just take the posterior values directly from the chains with the .get_traces() function. Those will be posteriors for the regression betas for v, and the posterior for the remaining parameters. 
From this you can reconstruct your regression using your covariates, and use the HDDM supplied basic simulators to get posterior predictives. Then you can construct any plot you want from that.

However, I think in principle posterior predictive sampling and corresponding plot should work if I remember correctly. 
Could you supply a more complete snippet of your code, to check whether the mistake made be on that level?

Best,
Ale

Kitti Ban

unread,
Sep 15, 2023, 8:07:11 AM9/15/23
to hddm-...@googlegroups.com
Hi Alex, 

Apologies for the late response, unfortunately, I've just seen your reply. The posterior predictive simulator function works, it's only the hddm.utils.plot_posterior_quantiles() and hddm.plotting.plot_posterior_predictive() functions that I can't get to work. When I try to use them, I get the following output: '<Figure size 800x600 with 0 Axes>'. 

Below is my code for running the neural regressions, any help would be much appreciated. 

Thank you so much,
Kitti

-------------------------------

# import
import pandas as pd
import matplotlib.pyplot as plt
import hddm
import mpmath
import numpy as np
import scipy
import pickle
import seaborn as sns
import csv

pd.set_option('display.max_columns', None)  # or 1000
pd.set_option('display.max_rows', None)  # or 1000
pd.set_option('display.max_colwidth', None)  # or 199

# load data
data = hddm.load_csv('/Users/kittib/Desktop/HDDM/FINAL MODELS/Data_HDDM_4origYs_n48.csv')

# using dictionary to convert specific columns
convert_dict1 = {'subj_idx':float,
                'rt': float,
                'response': float,
                'earlyposY': float,
                'earlynegY': float,
                'lateposY': float,
                'latenegY': float,
                 'pos_fdbk': float,
                 'neg_fdbk': float}

data = data.astype(convert_dict1)
print(data.dtypes)
print(data.head(10))
data1 = hddm.utils.flip_errors(data)

# Model 1: drift & boundary  
m1 = hddm.HDDMRegressor(data1, ["a ~ earlyposY + earlynegY + lateposY + latenegY",
                               "v ~ earlyposY + earlynegY + lateposY + latenegY"],
                       include = ['a', 'v', 't', 'z', 'sv', 'st', 'sz'])
m1.find_starting_values()
m1.sample(10000, burn=5000, thin=5, dbname='traces.db', db='pickle')

hddm.utils.plot_posterior_quantiles(m1)
hddm.plotting.plot_posterior_predictive(m1)



--
You received this message because you are subscribed to the Google Groups "hddm-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hddm-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hddm-users/dbf16426-9e57-4860-b3de-5fd2f8a8c98en%40googlegroups.com.

Guillaume Pagnier

unread,
Sep 28, 2023, 10:45:57 AM9/28/23
to hddm-users
Hi Kitti,
I've had that problem plots not showing up in the past (when I use hddm in jupyter notebook) and it stems from the order in which I call the figure plot. What worked for me is just having the command plt.show() be the last command. Afterwards 
plot_posterior_predictive() and plot_posterior_quantiles() should work. 
Alternatively, I employ Alex's strategy which is to export the posteriors (using the .get_traces() function) and then plot them separately. If you want to skip the process of reconstructing your regression model, you can use the function and assuming it's a hierarchical model grouped by subj_idx, you can use the following function: hddm.utils.post_pred_gen(m1,groupby=["subj_idx"],append_data=True,samples=100). This will generate a table you can convert to a csv that has simulated and empirical RTs and responses.
As a heads up, it may be worth installing HSSM. HDDM will become depreciated and HSSM is just a more general and efficient sequential sampling model package. 

Kitti Ban

unread,
Sep 29, 2023, 11:54:14 AM9/29/23
to hddm-...@googlegroups.com
Hi Guillaume, 

Thank you so much for your response! I tried the plotting functions with th plt.show() command in both Jupyter and Idle without success regarding the posterior predictive plots. I've eventually created customised graphs using the traces from the simulated data as suggested. Thank you for the heads-up about HSSM - I've actually tried it as well but found it more efficient to finish my project with the HDDM :) 

Thank you,
Kitti





Reply all
Reply to author
Forward
0 new messages