Getting all positive drift rates using regressor

166 views
Skip to first unread message

Camilla Eva Andersen

unread,
Sep 27, 2023, 4:05:10 AM9/27/23
to hddm-users
Hi

I am using HDDM on data I have collected in relation to thermosensation. Participants responded warm or cold based on a thermal stimulus in each round. Now I am using the HDDMregressor to model the data.

I have flipped the RTs so that all RTs for cold responses are negative and I have called the stim -1 for cold and 1 for warm.

However, the posterior drift rates for both warm and cold responses are positive. I don't understand how a posterior can be positive, if all the values it is based on are negative.

Here is my model (the area size is the size of the stimulus which is a number between 1 and 5):

v_rec_spc = 'v ~ 0 + C(stim, Treatment(0)) + C(stim, Treatment(0)) : area_size'
t_rec_spc = 't ~ 0 + C(stim, Treatment(0))'
rec_spc = [v_rec_spc, t_rec_spc]

samples = 10000
burn = 500


m_study1_s = [] # Empty list to fill in with loop



for i in range(2): # Run the model 5 times
    m_study1 = hddm.HDDMRegressor(data,
                               rec_spc,
                               informative = False,
                               bias = True,
                               include = ['z'],
                               p_outlier = 0.05,
                               is_group_model = False  # True when more participants
                              )
    m_study1.sample(samples, burn=burn, dbname='traces.db', db='pickle')
    m_study1_s.append(m_study1)


Did I define the model wrong, or is my understanding of the model wrong? Any help would be very appreciated :D

Michael J Frank

unread,
Sep 27, 2023, 7:27:24 AM9/27/23
to hddm-...@googlegroups.com
Did you mean you flipped RTs and coded them as negative in the data frame? One should not do that - the negative RTs are just for flipping them visually afterwards to observe RTs for both responses in a mirrored fashion and in comparison to posterior predictive checks. 

Also it depends on how you coded the “response” column. It is accuracy coded? If so a positive drift rate can still apply to the cold responses (ie if people respond correctly for cold and for warm, drift rates will be positive for each, though they could have different values depending on the relative speed and accuracy). If it’s stim coded and you have response  -1 for cold stimuli then it should have negative drift rates in that condition… but I’m not sure if your negative RTs are treated properly. 

To check if you get anything reasonable at all you can run a single model with just 1000 samples instead of 10000 and it should at least give you the right sign and be interpretable - then run a larger number of samples and chains to check for convergence etc 

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/e1f5c20d-3c89-43ac-83c5-40481e02488bn%40googlegroups.com.

Camilla Eva Andersen

unread,
Oct 4, 2023, 3:06:55 AM10/4/23
to hddm-users
Hi Michael,

Thank you so much for your reply!

I ran the model again without flipping the RTs. So now there are no negative RTs. The drift rates are still positive for both my conditions.
All_RTS_Positive.png

The strange thing is, when I test run the model with just one participant, I get the results I expect with one negative and one positive drift rate (2 examples of 2 different participants):

All_RTs_Positive_group_False.pngAll_Rts_positve_group_false_2.png
When I run the model for one participant, I set the group argument to false, and when I run the model for all participants, I set the group argument to true. Is that wrong?

Thanks,
Camilla

Michael J Frank

unread,
Oct 4, 2023, 8:01:05 AM10/4/23
to hddm-...@googlegroups.com
The drifts you are showing here are the interaction terms with area size, not the main effect of stim cold and warm. (Also when you do get negative posterior values it is for warm not cold). You might want to mean center your area size variable so that it ranges from -2 to +2 — that way your main drift rate effects can be interpreted as the drift for the average area size (when it’s 0). It would probably also be good to test a simpler model first that omits area size altogether just to see what the drift rates look like for each condition and if they align with what you expect. Again it depends on whether your response column in the data frame is accuracy coded (1 for corrects 0 for errors) or stim coded (1 for warm response and 0 for error response )

 M

Camilla Eva Andersen

unread,
Oct 6, 2023, 9:14:43 AM10/6/23
to hddm-users
Hi,

Thank you for your reply!

Here are the main effects (now with just 1000 samples) but they are also both negative. The response column is stim coded so warm is 0 and cold is 1.  
I also ran the model without the area size interaction as you suggested. That also results in both posterior drift rates being negative.

All_except_1.png


Then I ran all the participants one by one, and when running them separately for each participant, I always got one positive and one negative drift rate. These are two examples, but all the participants look somewhat like that.
2.png6.png


Am I missing something like a link function when stim coding the HDDM regressor?

Thanks,
Camilla

Michael J Frank

unread,
Oct 6, 2023, 1:16:41 PM10/6/23
to hddm-...@googlegroups.com
Hm that's odd. If all (or most) subjects show opposite sign drifts for the two conditions when fit individually this should also hold at the group level in a hierarchical model.

A few thoughts:
- I assume you use "is_group_model" is True when you fit the whole group and that you have the appropriate column indicating which subject is which (ie subj_idx) in the data frame?
- Have you also confirmed that the hierarchical model converges? (ie run multiple chains and look at the r-hat). 
- do all of your subjects have the same sign or is the case that some of them have positive v's for the blue cond and some negative v's for that cond? if so you might have just coded the response or stim differently per subject (eg if you counterbalanced responses) and lumping them together that way wouldn't work


More generally I always recommend confirming that you get interpretable parameters first based on simulated data (ie generate data with known parameters, and then fit those data to see if you get them back). THis should work both for individual subjects (if there is enough data /trials to recover the parameters) and for groups. 



 

Reply all
Reply to author
Forward
0 new messages