Error when using `pymc.ode.DifferentialEquation`

When you get a crypic shape error, my debugging procedure is:

  1. Comment out pm.sample
  2. Working from the bottom to the top, call .eval() on each of your model variables.

If your case, y.eval(), threw an error, so I did ode_solution.eval(), which did give me an output, but it was a column vector. So there’s the problem: you have an (n,1) matrix for mu but an (n,) vector for y_obs. You have to reshape one or the other, I chose to add a dimension to y_obs:

    y = pm.Normal("y", mu=ode_solution, sigma=sigma, observed=y_obs[:, None])

    trace = pm.sample(2000, tune=1000, cores=1)
2 Likes