Skip to content

Broadcasting error when using default intercept (1) on DDM model #844

@morgbead

Description

@morgbead

I am currently using HSSM on Google Colab, and have been working on tweaking some analyses over the last month or two using this package. The code below was working to define the model and sample the data up until recently - it is now producing a broadcasting error, specific verbiage being:

[/usr/local/lib/python3.12/dist-packages/pytensor/tensor/elemwise.py](https://localhost:8080/#) in _check_runtime_broadcast(node, inputs)
    740         ):
    741             if any(d != 1 for d, _ in dims_and_bcast) and (1, False) in dims_and_bcast:
--> 742                 raise ValueError(
    743                     "Runtime broadcasting not allowed. "
    744                     "At least one input has a distinct dimension length of 1, but was not marked as broadcastable.\n"

ValueError: Runtime broadcasting not allowed. At least one input has a distinct dimension length of 1, but was not marked as broadcastable.
If broadcasting was intended, use `specify_broadcastable` on the relevant input.

Here is the model definition and sampling code that was previously working:

# Model Definition
model1 = hssm.HSSM(
    model="ddm", )
    noncentered=False, 
    data=dat, # dataset
    prior_settings="safe", 
    include=[
        {
            "name": "v",
            "formula": "v ~ group",
            "link": "identity",
        },
        {
            "name": "a",
            "formula": "a ~ group",
            "link": "identity",
        },
        {
            "name": "z",
            "formula": "z ~ group",
            "link": "identity", 
        },
    ],
)

# Model Sampling
idata_m1 = model1.sample(
    sampler="nuts_numpyro",  
    cores=2,  
    chains=4,  
    draws=8000,  
    tune=4000,  
    target_accept=0.95,  
    idata_kwargs=dict(log_likelihood=True), 
)

The model will sample if I change the default intercept to 0 (in the model definition, alter the formula for each of the 3 parameters to be ~ 0 + group). It will also sample if I do not define the group parameter in the model, and instead use the default model settings, such as - model1 = hssm.HSSM(data = dat, model = "ddm"). It will not sample if I specify the formula to have an intercept of 1 (in the model definition, alter the formula for each of the 3 parameters to be ~ 1 + group).

Given the recent onset of this error on code that was previously working, I suspect that this is due to a recent update. I would be grateful if someone could offer advice on a way to define my model in a way that circumvents the error.

Happy to elaborate on any of the above! Thank you in advance for your time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions