Open const7 opened 2 years ago
Since this has remained unanswered for so long, here is a minimal working example tracing the problem to the issue mentioned above.
import hddm
data, params = hddm.generate.gen_rand_data(params={'easy': {'v': 1, 'a': 2, 't': .3},
'hard': {'v': 1, 'a': 2, 't': .3}})
## Defining m_reg using HDDMRegressor class:
m_reg = hddm.HDDMRegressor(data, 'v ~ condition',include=['v'])
m_reg.sample(1000, burn=20)
## Code adapted from kabuki/kabuki/analyze.py (50afecf):
## plot_posterior_predictive() L575-L580
## _plot_posterior_pdf_node() L466
m_reg_obs = m_reg.get_observeds()
m_reg_grp = m_reg_obs.groupby('tag')
m_reg_nodes = list(m_reg_grp.groups.values())
if hasattr(m_reg_obs['node'].loc[m_reg_nodes[0][0]],'pdf')
print("Node in {0} has pdf".format(type(m_reg)))
else:
print("Node in {0} does not have pdf".format(type(m_reg)))
## Defining m using HDDM class
m = hddm.HDDM(data,include=['v'],depends_on={'v':'condition'})
m.sample(1000,burn=20)
m_obs = m.get_observeds()
grp = m_obs.groupby('tag')
nodes = list(grp.groups.values())
if hasattr(m_obs['node'].loc[nodes[0][0]],'pdf')
print("Node in {0} has pdf".format(type(m)))
else:
print("Node in {0} does not have pdf".format(type(m)))
## This is why plot_posterior_predictive() is generating an empty plot
## for nodes in models defined by HDDMRegressor class.
Nodes in models defined by HDDM are Wfpt objects, with a pdf method. Nodes in models defined by HDDMRegressor are WfptReg objects, which do not have a pdf method.
@const7 @promitmoitra
Thanks for reporting this issue. I think Alex is busy with the release of the new HSSM. However, @Asynchro-Epool and I are working on a docker image that keep the funcationality of HDDM, we will try to figure this issue when we wrap the HDDM 0.9.8 into the docker image, but we are still working on it, will update our progress here.
plot_posterior_predictive
plot nothing when usingHDDMRegressor
with only a hint like<Figure size 576x432 with 0 Axes>
in at least both HDDM0.8.0
&0.9.7
.Minimal code to reproduce:
When I traced the code I found that model nodes generated by
HDDMRegressor
don't have thepdf
method. Not sure whether it's normal. https://github.com/hddm-devs/kabuki/blob/50afecf96796b426d3191d31b7665bcb4aad8e2f/kabuki/analyze.py#L577-L580