lnccbrown / HSSM

Development of HSSM package
Other
71 stars 10 forks source link

Request for code tutorial on handling multiple subjects and experimental conditions using the low-level API in HSSM package #254

Open YuanboBQ opened 11 months ago

YuanboBQ commented 11 months ago

Hello, I hope this message finds you well. I have been exploring the capabilities of the HSSM package and found the documentation on "Using the low-level API from HSSM directly with PyMC" quite helpful. However, I am currently facing a challenge in handling multiple subjects and multiple experimental conditions within my analysis.

I would greatly appreciate it if you could provide a code tutorial or example demonstrating how to effectively handle multiple subjects and experimental conditions using the low-level API in HSSM. This would be immensely beneficial for researchers working with complex experimental designs and large datasets.

I am looking forward to your response.

Best regards, Bo

YuanboBQ commented 11 months ago

I try to use the following codes to handle multiple subjects:

with pm.Model() as multi_sub_ddm_pymc:
    v = pm.Uniform("v", lower=-10.0, upper=10.0, shape=n_subj)
    a = pm.HalfNormal("a", sigma=2.0, shape=n_subj) #, shape=n_subj
    z = pm.Uniform("z", lower=0.01, upper=0.99, shape=n_subj)
    t = pm.Uniform("t", lower=0.0, upper=0.6, initval=0.1, shape=n_subj)

    ddm = DDM("ddm", v=v[suj_idx], a=a[suj_idx], z=z[suj_idx], t=t[suj_idx], 
    observed=obs_ddm[["rt", "response"]].values)

but get the following error: TypeError: Wrong number of dimensions: expected 1, got 0 with shape ().

AlexanderFengler commented 10 months ago

Hi YuanBo,

sorry for the belated answer this slipped my radar.

I think what happens here is that the DDM random variable expects you to pass parameters as either scalars or n by 1 matrices, so you can try to add the extra dimension.

But we should prob make this more robust to allow for more initial shapes, we will double check that.

Best, Alex