Broadcasting error when using default intercept (1) on DDM model
- Dominant language
- Python
- Stars
- 124
- Forks
- 24
- Avg merge
- 19h 32m
- Merged PRs (30d)
- 60
Description
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.
Contributor guide
Research direction
Start by reproducing the reported HSSM DDM model and sampling call in the issue, comparing formulas with the default intercept, `~ 0 + group`, and `~ 1 + group`. Trace the model-building path into the PyTensor broadcasting error; done means the default-intercept model samples successfully without the runtime broadcasting exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100