Hi HDDMnn'ers,
Perhaps I'm a bit late to the party, but today I started playing with the HDDMnn extensions and I'm very excited about all the new possibilities! Thanks for your great work on this. Hopefully switching to pyDDM just for collapsing bounds won't be necessary anymore.
My question: can HDDMnnRegression accept non-identity link functions?
Explanation:
I started by implementing a very basic regression model, which I usually run in the standard HDDM:
v_reg = {'model': 'v ~ 1 + stimulus + prevresp', 'link_func': lambda x:x}
z_reg = {'model': 'z ~ 1 + prevresp', 'link_func': z_link_func}
m = hddm.HDDMRegressor(data, [v_reg, z_reg],
include=['z', 'sv'], group_only_nodes=['sv'],
group_only_regressors=False, keep_regressor_trace=False,
p_outlier=0.05)
Now, switching to the HDDMnnRegressor module, only regressing onto drift works beautifully
regr_md = {'model': 'v ~ 1 + stimulus + prevresp', 'link_func': lambda x: x}
# keep things as similar as possible to the usual DDM for now
hddmnn_reg = hddm.HDDMnnRegressor(data,
regr_md,
include = ['z'], # 'sv' is not allowed here
model = 'ddm',
informative = False,
is_group_model = True, # hierarchical model
group_only_regressors = False, # fit one parameter for each subject
p_outlier = 0.05)
But adding in a regression model for starting point doesn't work:
# Make HDDM model
def z_link_func(x):
return 1 / (1 + np.exp(-(x.values.ravel())))
#ToDo: transform the z-param so it can find the right bounds?
regr_md = [{'model': 'v ~ 1 + stimulus', 'link_func': lambda x: x},
{'model': 'z ~ 1', 'link_func': z_link_func}]
# keep things as similar as possible to the usual DDM for now
hddmnn_reg = hddm.HDDMnnRegressor(data,
regr_md,
include = ['z'], # 'sv' is not allowed here
model = 'ddm',
informative = False,
is_group_model = True, # hierarchical model
group_only_regressors = False, # fit one parameter for each subject
p_outlier = 0.05)
returns
Reg Model:
{'outcome': 'v', 'model': ' 1 + stimulus', 'params': ['v_Intercept', 'v_stimulus'], 'link_func': <function <lambda> at 0x7f12f31aa320>}
Uses Identity Link
Reg Model:
{'outcome': 'z', 'model': ' 1', 'params': ['z_Intercept'], 'link_func': <function z_link_func at 0x7f12f33d70e0>}
Does not use Identity Link
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-24-542f6154eee0> in <module>()
16 is_group_model = True, # hierarchical model
17 group_only_regressors = False, # fit one parameter for each subject
---> 18 p_outlier = 0.05)
8 frames
/usr/local/lib/python3.7/dist-packages/hddm/models/hddm_regression.py in _create_stochastic_knodes(self, include)
452 param_lookup = param
453
--> 454 reg_parents[param] = reg_family["%s_bottom" % param_lookup]
455 if reg not in self.group_only_nodes:
456 reg_family["%s_subj_reg" % param] = reg_family.pop(
KeyError: 'z_Intercept_bottom'
Can I somehow indicate in the call to HDDMnnRegressor that the z-regression dict should be transformed?
Thanks a lot for any pointers!
Anne Urai, Leiden University