I’m tryin to sample a generalized Pareto using DensityDists, as it is not implemented natively by PyMC3. Here’s a minimal working example:
import numpy as np
import pymc3 as pm
import theano
import theano.tensor as tt
#gp loglikelihood
def tegpd_logp(x,eta,sigma):
#returns the sum of log-liklihoods
return tt.sum(-tt.log(sigma) - (1.0/eta+1)*tt.log(1+eta/sigma*x))
obs = np.random.exponential(size=1000).reshape(1000,1)
n_samples = 100
#obs = tt.stacklists(obs)
eta_model = pm.Model()
with eta_model:
#uniform eta prior in (0,1)
eta = pm.Uniform("eta",lower=0,upper=1)
#flat sigma prior in positive line
sigma = pm.HalfFlat("sigma")
X = pm.DensityDist("tegpd_logp",logp=tegpd_logp,observed=dict(eta=eta,sigma=sigma,x=obs))
trace = pm.sample(1000)
I’m getting the following output and error, and I don’t know what I’m missing:
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
Multiprocess sampling (2 chains in 2 jobs)
NUTS: [sigma, eta]
Sampling 2 chains for 1_000 tune and 1_000 draw iterations (2_000 + 2_000 draws total) took 3 seconds.
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
File "/home/nestor/progs/phd/bivariate_tc/R/net_demand_asymptotic_dep/py/pymc3/pymc3/sampling.py", line 619, in sample
idata = arviz.from_pymc3(trace, **ikwargs)
File "/home/nestor/.local/share/virtualenvs/py-b4UU9nVN/lib/python3.6/site-packages/arviz/data/io_pymc3.py", line 531, in from_pymc3
save_warmup=save_warmup,
File "/home/nestor/.local/share/virtualenvs/py-b4UU9nVN/lib/python3.6/site-packages/arviz/data/io_pymc3.py", line 159, in __init__
self.observations, self.multi_observations = self.find_observations()
File "/home/nestor/.local/share/virtualenvs/py-b4UU9nVN/lib/python3.6/site-packages/arviz/data/io_pymc3.py", line 172, in find_observations
multi_observations[key] = val.eval() if hasattr(val, "eval") else val
File "/home/nestor/.local/share/virtualenvs/py-b4UU9nVN/lib/python3.6/site-packages/theano/gof/graph.py", line 522, in eval
self._fn_cache[inputs] = theano.function(inputs, self)
File "/home/nestor/.local/share/virtualenvs/py-b4UU9nVN/lib/python3.6/site-packages/theano/compile/function.py", line 317, in function
output_keys=output_keys)
File "/home/nestor/.local/share/virtualenvs/py-b4UU9nVN/lib/python3.6/site-packages/theano/compile/pfunc.py", line 486, in pfunc
output_keys=output_keys)
File "/home/nestor/.local/share/virtualenvs/py-b4UU9nVN/lib/python3.6/site-packages/theano/compile/function_module.py", line 1839, in orig_function
name=name)
File "/home/nestor/.local/share/virtualenvs/py-b4UU9nVN/lib/python3.6/site-packages/theano/compile/function_module.py", line 1487, in __init__
accept_inplace)
File "/home/nestor/.local/share/virtualenvs/py-b4UU9nVN/lib/python3.6/site-packages/theano/compile/function_module.py", line 181, in std_fgraph
update_mapping=update_mapping)
File "/home/nestor/.local/share/virtualenvs/py-b4UU9nVN/lib/python3.6/site-packages/theano/gof/fg.py", line 175, in __init__
self.__import_r__(output, reason="init")
File "/home/nestor/.local/share/virtualenvs/py-b4UU9nVN/lib/python3.6/site-packages/theano/gof/fg.py", line 346, in __import_r__
self.__import__(variable.owner, reason=reason)
File "/home/nestor/.local/share/virtualenvs/py-b4UU9nVN/lib/python3.6/site-packages/theano/gof/fg.py", line 391, in __import__
raise MissingInputError(error_msg, variable=r)
theano.gof.fg.MissingInputError: Input 0 of the graph (indices start from 0), used to compute sigmoid(eta_interval__), was not provided and not given a value. Use the Theano flag exception_verbosity='high', for more information on this error.
I haven’t been able to find anything concrete online, any help would be appreciated.