Thanks for the example, I did not know that modeling covariates as coming from distributions is a valid way. However, with the code above, I get the following error:
Traceback (most recent call last):
File "/home/guet_jn/Desktop/modelbase/mb_modelbase/models_core/tests/create_PyMC3_testmodels.py", line 292, in <module>
mu = pm.Normal('mu', mu=X, sd=1)
File "/home/guet_jn/anaconda3/envs/modelbase/lib/python3.5/site-packages/pymc3/distributions/distribution.py", line 42, in __new__
return model.Var(name, dist, data, total_size)
File "/home/guet_jn/anaconda3/envs/modelbase/lib/python3.5/site-packages/pymc3/model.py", line 808, in Var
total_size=total_size, model=self)
File "/home/guet_jn/anaconda3/envs/modelbase/lib/python3.5/site-packages/pymc3/model.py", line 1208, in __init__
self.logp_elemwiset = distribution.logp(self)
File "/home/guet_jn/anaconda3/envs/modelbase/lib/python3.5/site-packages/pymc3/distributions/continuous.py", line 447, in logp
return bound((-tau * (value - mu)**2 + tt.log(tau / np.pi / 2.)) / 2.,
File "/home/guet_jn/anaconda3/envs/modelbase/lib/python3.5/site-packages/theano/tensor/var.py", line 147, in __sub__
return theano.tensor.basic.sub(self, other)
File "/home/guet_jn/anaconda3/envs/modelbase/lib/python3.5/site-packages/theano/gof/op.py", line 615, in __call__
node = self.make_node(*inputs, **kwargs)
File "/home/guet_jn/anaconda3/envs/modelbase/lib/python3.5/site-packages/theano/tensor/elemwise.py", line 482, in make_node
DimShuffle, *inputs)
File "/home/guet_jn/anaconda3/envs/modelbase/lib/python3.5/site-packages/theano/tensor/elemwise.py", line 438, in get_output_info
['x'] * difference + list(range(length)))(input))
File "/home/guet_jn/anaconda3/envs/modelbase/lib/python3.5/site-packages/theano/gof/op.py", line 625, in __call__
storage_map[ins] = [self._get_test_value(ins)]
File "/home/guet_jn/anaconda3/envs/modelbase/lib/python3.5/site-packages/theano/gof/op.py", line 562, in _get_test_value
ret = v.type.filter(v.tag.test_value)
File "/home/guet_jn/anaconda3/envs/modelbase/lib/python3.5/site-packages/theano/tensor/type.py", line 178, in filter
data.shape))
TypeError: For compute_test_value, one input test value does not have the requested type.
The error when converting the test value to that variable type:
Wrong number of dimensions: expected 0, got 1 with shape (100,).
Process finished with exit code 1
Any idea where this might come from? I thought this was because the X is not a scalar, that’s why I thought arrays are not accepted in distributions. Thanks for the help!