Regression stim coding

273 views
Skip to first unread message

Camilla Eva Andersen

unread,
Sep 20, 2022, 4:56:46 AM9/20/22
to hddm-users
Hi everyone.

I am fitting a dataset with 340 trials, two stimulus outcomes (warm and cold), where participants categorize the stimulus as fast as possible.

We also have a within-subject condition of the stimulated areas of skin, from 1-5. I’m using the HDDM/HDDMnn package to model these data, and want to test for an interaction between stimulus and skin area on drift, bias, and threshold.

I’m new to this kind of model so I was hoping to check if I’ve parameterized my link function and model correctly. Additionally, I would love to use the HDDMnn for this, but the code does not work if I change the 'hddm.HDDMRegressor' to 'hddm.HDDMnnRegressor', because then I get the error: Using default priors: Uninformative Supplied model_config specifies params_std_upper for z_Intercept as None. Changed to 10 After 7.000000 retries, still no good fit found.

My data has these columns:

  • subj_idx
  • AreaSize
  • rt
  • stim
  • response

Link function:
def z_link_func(x, data=data):
stim = (np.asarray(dmatrix('0 + C(s, [[0], [1]])',
{'s': data.stim.loc[x.index]},return_type='dataframe'))
)
# Apply z = (1 - x) to flip them along 0.5
z_flip = np.subtract(stim, x.to_frame())
# The above inverts those values we do not want to flip,
# so invert them back
z_flip[stim == 0] *= -1
return z_flip

z_reg = {'model': 'z ~ 1 + C(AreaSize)', 'link_func': z_link_func}
v_reg = {'model': 'v ~ 1 + C(AreaSize)', 'link_func': lambda x: x}
reg_descr = [z_reg, v_reg]

Model:
m_reg = hddm.HDDMRegressor(data, reg_descr, include='z',
keep_regressor_trace=True,
p_outlier=0.05)

m_reg.sample(10000, burn=1000)













Michael J Frank

unread,
Sep 21, 2022, 10:35:38 AM9/21/22
to hddm-...@googlegroups.com
Hi Camilla, 

when you use C(AreaSize) it will create categorical estimates of the z and v parameters for each areasize. Assuming areaSize is continuous you might want to just make this a linear regression so that you can estimate the impact of areasize with just a single slope. This will be a simpler model to estimate (far fewer parameters). 

It's also always a good idea to generate simulated data where you allow z or v to vary in the way you are testing, and then see if your regression models then properly recover those parameters, which give you a sanity check (I think we have that in the tutorial). 

Alex can weigh in on what might be happening for the HDDMnn version but I suspect it is that the model ends up sampling values that lie outside the range of allowable z parameters or those in which the NN was trained, given that no informative priors have been used. We are working on including informative priors that can also be specified by the user. But you should probably work these things out first with regular HDDM. 

M

--
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/b721c051-47be-4425-b03d-3edd485aa54cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages