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
261 stars 117 forks source link

Possible conflict setting related to `depends_on` in hddm 0.8.0 #92

Closed const7 closed 2 years ago

const7 commented 2 years ago

When I run with the default HDDM like the following I found it fits all four parameters v, a, t, z (according to the document here z should be explicitly set by user, but z is actually implicitly included in the basic DDM from model_config) and everything works fine:

model = hddm.HDDM(data) # or
model = hddm.HDDM(data, depends_on={"v": "group"}) # or
model = hddm.HDDM(data, depends_on={"a": "group"}) # or
model = hddm.HDDM(data, depends_on={"t": "group"})

However when I tried to set depends_on for z like this:

model = hddm.HDDM(data, depends_on={"z": "group"})

I got the following error

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
/home/haiyanwu/Documents/OT-neural-variability/step3_1_ddms.ipynb Cell 18 in <cell line: 1>()
----> [1](vscode-notebook-cell://ssh-remote%2B7920/home/haiyanwu/Documents/OT-neural-variability/step3_1_ddms.ipynb#X55sdnNjb2RlLXJlbW90ZQ%3D%3D?line=0) model = hddm.HDDM(data, depends_on={"z": "group"})

File ~/miniconda3/envs/hddm/lib/python3.8/site-packages/hddm/models/hddm_info.py:113, in HDDM.__init__(self, *args, **kwargs)
    106 self.emcee_dispersions = {'a':1, 't': 0.1, 'a_std': 1, 't_std': 0.15, 'sz': 1.1, 'v': 1.5,
    107                           'st': 0.1, 'sv': 3, 'z_trans': 0.2, 'z': 0.1,
    108                           'p_outlier':1., 'v_std': 1, 'alpha': 1.5, 'pos_alpha': 1.5}
    111 self.is_informative = kwargs.pop('informative', True)
--> 113 super(HDDM, self).__init__(*args, **kwargs)

File ~/miniconda3/envs/hddm/lib/python3.8/site-packages/hddm/models/base.py:729, in HDDMBase.__init__(self, data, bias, include, wiener_params, p_outlier, **kwargs)
    726 #set wfpt class
    727 self.wfpt_class = hddm.likelihoods.generate_wfpt_stochastic_class(wp, cdf_range=self.cdf_range)
--> 729 super(HDDMBase, self).__init__(data, **kwargs)

File ~/miniconda3/envs/hddm/lib/python3.8/site-packages/hddm/models/base.py:40, in AccumulatorModel.__init__(self, data, **kwargs)
     37 data = hddm.utils.flip_errors(data)
     38 self.std_depends = kwargs.pop('std_depends', False)
---> 40 super(AccumulatorModel, self).__init__(data, **kwargs)

File ~/miniconda3/envs/hddm/lib/python3.8/site-packages/kabuki/hierarchical.py:348, in Hierarchical.__init__(self, data, is_group_model, depends_on, trace_subjs, plot_subjs, plot_var, group_only_nodes)
    345 self.dbname = 'ram'
    346 self.db = None
--> 348 self._setup_model()

File ~/miniconda3/envs/hddm/lib/python3.8/site-packages/kabuki/hierarchical.py:359, in Hierarchical._setup_model(self)
    356     knode.set_data(self.data)
    358 # constructs pymc nodes etc and connects them appropriately
--> 359 self.create_model()

File ~/miniconda3/envs/hddm/lib/python3.8/site-packages/kabuki/hierarchical.py:445, in Hierarchical.create_model(self, max_retries)
    442 self.create_nodes_db()
    444 # Check whether all user specified column names (via depends_on) where used by the depends_on.
--> 445 assert set(flatten(list(self.depends.values()))).issubset(set(flatten(self.nodes_db.depends))), "One of the column names specified via depends_on was not picked up. Check whether you specified the correct parameter value."

AssertionError: One of the column names specified via depends_on was not picked up. Check whether you specified the correct parameter value.

When I add include={"z"} or bias=True everything works fine (But it's actually already included in the basic model).

So there are maybe some conflicts when detecting whether z is included. Please correct me if I am wrong.

const7 commented 2 years ago

It seems something is wrong in my local environment. z is not default included.