Hello everyone,
I’m currently trying to do some Bayesian inference to do parameters estimation on a model. Part of this model (the v variable below) is an iterative map: “v_{t+1} = delta*v_t + gamma”. This iterative map gets plugged into a deterministic equation (shares in the code below). I am trying to obtain parameters alpha/beta/delta (gamma is a known value) in my model. What would be the best way for me to handle this, since I can’t think of any way to get that iterative map value without some sort of for loop? Right now I get the error: “TypeError: Unsupported dtype for TensorType: object”.
Also any other feedback on what I might be doing wrong is appreciated, I am very new to Bayesian inference and pymc.
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import pymc as pm
import arviz as az
tweet_model = pm.Model()
with tweet_model:
alpha = pm.Uniform("alpha", lower=-30, upper=700)
beta = pm.LogNormal("beta", mu=0, sigma=2)
delta = pm.Beta("delta", alpha=5, beta=1)
v = np.array([0])
for i in range(first_index['index']):
v = np.append(v, delta*v + data.gamma())
shares = alpha*(pm.math.exp(beta*v) - 1/(v+1))
Y_obs = pm.Normal("Y_obs", mu=shares, sigma=1, observed=Y)
trace_g = pm.sample(2000, tune=1000, cores=2)
az.summary(trace_g)
chain_count = trace_g.get_values('delta').shape[0]
y_pred_g = pm.sample_posterior_predictive(trace_g, samples=chain_count, model=model_g)
data_spp = az.from_pymc3(trace=trace_g, posterior_predictive=y_pred_g)