# Shape error after pm.math.dot in multivar logistic regression model

**URL:** <https://discourse.pymc.io/t/shape-error-after-pm-math-dot-in-multivar-logistic-regression-model/3848>\
**Category:** Questions\
**Created:** [September 11, 2019, 5:58pm UTC](https://discourse.pymc.io/t/shape-error-after-pm-math-dot-in-multivar-logistic-regression-model/3848 "2019-09-11T17:58:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arainboldt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/arainboldt/32/6273_2.png) [@arainboldt](https://discourse.pymc.io/u/arainboldt)\
**Post date:** [September 11, 2019, 5:58pm UTC](https://discourse.pymc.io/t/shape-error-after-pm-math-dot-in-multivar-logistic-regression-model/3848/1 "2019-09-11T17:58:32Z")

</div>

I’m trying to create a multivariate logistic regression model using one-hot encoded data. The model runs through find\_MAP fine, but stalls at the start of sampling. I’m thinking this might be related to this issue:

> <https://github.com/pymc-devs/pymc3/issues/884>

and perhaps:

> <https://github.com/pymc-devs/pymc3/issues/555>

The data is a one-hot encoded numpy.array with shape (5800,170) and y is a binary (5800,)

I’ve tried it with the NUTS and Metropolis samplers, to no avail. Any ideas or suggestions?

The model is defined below:

```
with pm.Model():
    betas = pm.Normal(name='beta', mu=0, sigma=3, shape=D)
    alpha = pm.Normal(name='alpha', mu=0, sigma=3)
    theta = pm.Deterministic('theta',pm.math.sigmoid(alpha + pm.math.dot(X, betas)))
    obs = pm.Bernoulli('obs', p=theta, observed=y)
    print("Finished GLM")
    start = pm.find_MAP()
    print("Finished MAP")
    print(start)
    step = pm.NUTS(scaling=start, step_scale=.25)
    trace = pm.sample(1000, step, start=start)
```

---

<div class="post-metadata">

**Author:** ![aseyboldt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/aseyboldt/32/5795_2.png) [@aseyboldt](https://discourse.pymc.io/u/aseyboldt)\
**Post date:** [September 12, 2019, 2:09am UTC](https://discourse.pymc.io/t/shape-error-after-pm-math-dot-in-multivar-logistic-regression-model/3848/2 "2019-09-12T02:09:04Z")

</div>

Setting scaling=start will only hurt you. Just use the normal settings from pm.sample(), ie just

```auto
trace = pm.sample()

```

or maybe

```auto
trace = pm.sample(tune=1000, draws=1000, target_accept=0.9)

```

Usually, you should only change `tune`, `draws`, `cores`, `chains` and `target_accept`.

Are there any nans in `y` or strange values in `X`?  
Are the columns of X strongly collinear? If so, you could fix that using a QR decomposition.
