Dear Maximilia, Dear Blairs,
thank you for the discussion so far, this has been really helpful to me. I was confused about the same thing, i.e. how to implement a model where all four parameters (v,a,z,t) are allowed to vary between two within-subject conditions. After your discussion, I am close to the solution, however one difficulty remains in adding the response bias "z" to the model properly.
About the task, it is a simple decision-making task (think random dot motion task), where I compare blocks with speed instructions ("fast choice") and blocks with accuracy instructions ("accurate choice"). 60 participants completed 160 trials of each block. My data file is organized so that in a "response" -column leftward responses are coded as 0 and rightward responses are coded as 1. If I understand correctly, this is "stimulus-coding". I use stimulus-coding, because I want to add the response bias z to the model and I want to allow it to vary between fast and accurate choice blocks.
So far, I have defined regressors for v, a and t as this:
v_reg = {'model': "v ~ C(block,Treatment('accurate_decision'))", 'link_func': lambda x: x}
a_reg = {'model': "a ~ C(block,Treatment('
accurate _decision'))" , 'link_func': lambda x: x}
t_reg = {'model': "t ~ C(block,Treatment('
accurate_decision'))" , 'link_func': lambda x: x}
reg_descr = [v_reg, a_reg, t_reg]I can then define the model without the response bias as
m_vat = hddm.HDDMRegressor(df, reg_descr, group_only_regressors=False, keep_regressor_trace = True, p_outlier=0.05)
The problem that I am facing right now is adding the parameter z correctly to this within-subjects model. According to the tutorial, I have to define a link-function for the z-parameter first:
def z_link_func(x, data=df):
stim = (np.asarray(dmatrix('0 + C(s, [[1], [-1]])',
{'s': data.stimulus.ix[x.index]}))
)
return 1 / (1 + np.exp(-(x * stim)))
Then I can define the regressor for the z-parameter as:
z_reg = {'model': "z ~ C(block,Treatment('slow_decision'))", 'link_func': z_link_func}
My first question is 1) Do I have to use data.stimulus.ix for the link function (i.e. the column which indicates which stimulus was shown, i.e. a leftward dot motion or a rightward dot motion) or do I have to use data.response.ix for the link function (i.e. the column which indicates whether participants responded as left or right). My second question is 2) Which entries should be coded as 1 and which as -1 in the link-funtion? Or is it arbitrary? My third question is 3) Is there any way to add the z-parameter and allowing it to vary between conditions without defining a link-function and finally 4) How do I properly recover z-parameter values for this within-subject design after model fitting?
These questions arise because I already tried to fit a full model with all four parameters (v, a, z, t) just like described above. However I am unsure whether I did everything correctly or whether I should include the z-parameter in a different way. I noticed that traces for all parameters seemed fine, with the exception of the z-parameter, whose traces were looking messy and showed a lot of autocorrelation.
Thank you for any advice. Have a great day!
Thomas