hddm-devs / hddm

HDDM is a python module that implements Hierarchical Bayesian parameter estimation of Drift Diffusion Models (via PyMC).
http://ski.clps.brown.edu/hddm_docs/
Other
268 stars 119 forks source link

Issues with indexing conditions of experiment #57

Closed Geskywalker closed 4 years ago

Geskywalker commented 4 years ago

New to Python and HDDM. I have run into the following problem:

One of the conditions of the experiment is how the coherence of dots differ. The coherence ratings are 0, 0.025, 0.05, 0.1, 0.15, 0.25, 0.35, 0.45 and 0.7. After building a model looking at drift rate 'v' and boundary threshold 'a' that depends on the different coherence conditions I've been getting some errors when trying to plot the posteriors. The error message is for posterior plots and not the models but I have put the model code so you can see the model.

1 Drift rate

m_stim = hddm.HDDM(data, depends_on={'v': 'stim'}, p_outlier=.05)
m_stim.find_starting_values()
m_stim.sample(10000, burn=1000, thin = 5)

v_7, v_45, v_35, v_25, v_15, v_1, v_05, v_025, v_0 = m_stim.nodes_db.node[['v(0.7)', 'v(0.45)', 'v(0.35)', 'v(0.25)', 'v(0.15)', 'v(0.1)', 'v(0.05)', 'v(0.025)', 'v(0)']]
hddm.analyze.plot_posterior_nodes([v_7, v_45, v_35, v_25, v_15, v_1, v_05, v_025, v_0])
plt.xlabel('drift-rate')
plt.ylabel('Posterior probability')
plt.title('Posterior of drift-rate group means')
plt.savefig('hddm_demo_fig_06.pdf')  

KeyError: u"None of [Index([u'v(0.7)', u'v(0.45)', u'v(0.35)', u'v(0.25)', u'v(0.15)', u'v(0.1)',\n       u'v(0.05)', u'v(0.025)', u'v(0)'],\n      dtype='object')] are in the [index]" 

2 Boundary Threshold

a_stim = hddm.HDDM(data, depends_on={'a': 'stim'}, p_outlier=.05)
a_stim.find_starting_values()
a_stim.sample(10000, burn=1000, thin = 5)

a_7, a_45, a_35, a_25, a_15, a_1, a_05, a_025, a_0 = a_stim.nodes_db.node[['a(0.7)', 'a(0.45)', 'a(0.35)', 'a(0.25)', 'a(0.15)', 'a(0.1)', 'a(0.05)', 'a(0.025)', 'a(0)']]
hddm.analyze.plot_posterior_nodes([a_7, a_45, a_35, a_25, a_15, a_1, a_05, a_025, a_0])
plt.xlabel('Threshold Boundary')
plt.ylabel('Posterior probability')
plt.title('Posterior of Threshold Boundary group means in coherence')
plt.savefig('hddm_demo_fig_ThresholdBoundary.pdf') 

AttributeError: 'float' object has no attribute 'trace'

Although they are different Error messages I am guessing they have the same reason behind them and that its related to the nodes.

All help appreciated and thank you in advance!

twiecki commented 4 years ago

Can you post this on the mailing list please?

Geskywalker commented 4 years ago

Hey Thomas,

I have posted on mailing list.

Thanks.

Best, Gabrielle


From: Thomas Wiecki notifications@github.com Sent: Thursday, February 27, 2020 7:56 AM To: hddm-devs/hddm hddm@noreply.github.com Cc: Sheehan, Gabrielle gabrielle.sheehan@ucl.ac.uk; Author author@noreply.github.com Subject: Re: [hddm-devs/hddm] Issues with indexing conditions of experiment (#57)

Can you post this on the mailing list please?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/hddm-devs/hddm/issues/57?email_source=notifications&email_token=AOVK5ZX56XQWMW5QTT42GP3RE5W4RA5CNFSM4K4L3L52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENDKUMA#issuecomment-591833648, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOVK5ZWWV5FLW65IQHVV3DTRE5W4RANCNFSM4K4L3L5Q.

twiecki commented 4 years ago

Great, now I can ignore it there ;) (just kidding)