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

running within-subject model #68

Open sleepmam opened 3 years ago

sleepmam commented 3 years ago

Following this link(http://ski.clps.brown.edu/hddm_docs/tutorial_python.html#within-subject-effects), I’m trying to run within-subject analysis, and I have a few questions regarding model specification. Here is a list of three variables that I’m interested in. Session - 2 levels of “behav”, “fmri” Condition - 2 levels of “Black”, “Like” Diff (difficulty) - 2 levels of “1”, “0”

My primary goal is to compare subject performance between “fmri” and “behav” sessions. For example, for those in easy & Black condition (diff =0, condition = Black), do those in (session = behav) differ from those in (session = fmri)?

Using pseudo-code, I need an intercept of Black_easy_behav -> black[black] : easy[easy] : behav[behav] And second term of Black_easy_fmri -> black[black] : easy[easy] : behav[fmri] waiting to be compared.

Using this input, I type - m_within = hddm.HDDMRegressor(data, "a ~ C(session, Treatment('fmri')):C(condition, Treatment('Black')):C(diff, Treatment(0))") I get this - [‘a_Intercept’, ..., “a_C(session, Treatment(‘fmri’))[T.behav]:C(condition, Treatment(‘Black’))[T.Like]:C(diff, Treatment(0))[T.1]”] While I have the intercept term, the second term is not what I wanted. I was looking for something like this -> “a_C(session, Treatment(‘fmri’))[T.behav]:C(condition, Treatment(‘Black’))[T.Black]:C(diff, Treatment(0))[T.0]”]

In summary, my questions are

  1. How do I get the specified results that I need? I’m a bit confused by how the co-variates are added. I can output the right combination (222, all8) by having > m_within = hddm.HDDMRegressor(data, "a ~ 0 + C(session, Treatment('fmri')):C(condition, Treatment('Black')):C(diff, Treatment(0))") Then I have this error. Also not sure how to solve. > AssertionError: Step-out procedure failed
  2. What would the intercept be if there are more than 1 term? In the tutorial, there intercept is only 1 variable. However, if mine has more variables for intercept, what does it become? Case 1: a ~ A:B, in this case I assume intercept is A:B. Case2: a ~ A:B + B:C, would intercept be A:B, or the combination of (A:B + B:C)
  3. What's the difference between C(diff, Treatment(1))[T.0] vs. C(diff, Treatment(0))[0]?
  4. Why sometimes there is [T.0], sometimes its just [0]? I’ve already made them “factors” rather than “integer/numbers” via R. Upon comparing my results and those from the Demo, I see a divergence from very early on here -

Where the Demo has > from patsy import dmatrix dmatrix("C(stim, Treatment('WL'))", data.head(10)) and outputs all levels > DesignMatrix with shape (10, 3) Intercept C(stim, Treatment('WL'))[T.LL] C(stim, Treatment('WL'))[T.WW] My line of ... > from patsy import dmatrix("C(condition, Treatment('Black'))", data.head(10)) only generates the following with out the other conditions. I hope to see something like "C(condition, Treatment('Black'))[T.Like]" > DesignMatrix with shape (10, 1) Intercept Whats more, if I type > dmatrix("C(condition, Treatment('Like'))", data.head(10)) I got result of this. and I wasn't sure what caused the level issue. `> PatsyError: specified level 'Like' not found

Thank you so much in advance!