import pymc as mc
# Priors
prior_eps = mc.Gamma('eps', 0.5, 1)
prior_eta = mc.Gamma('eta', 0.5, 1)
# Create the model for likelihood evaluation
model = sm.tsa.UnobservedComponents(nile, 'local level')
# Create the "data" component (stochastic and observed)
@mc.stochastic(dtype=sm.tsa.statespace.MLEModel, observed=True)
def loglikelihood(value=model, eps=prior_eps, eta=prior_eta):
return value.loglike([1 / eps, 1 / eta])
# Create the PyMC model
pymc_model = mc.Model((prior_eps, prior_eta, loglikelihood))
# Create a PyMC sample and perform sampling
sampler = mc.MCMC(pymc_model)
sampler.sample(iter=10000, burn=1000, thin=10)
In
Local Level - Nile.ipynb, running the following cell generated an error indicating@mc.stochastic()caused the problemI think this is because
pymcchanged its APIs.I wonder if you have an idea of how to update the code to make it work.