Hi,
I am interested in conducting a Bayesian AR(1) regression. The variable I intend to model should not possess negative values. Therefore, I have opted for a Beta distribution as the likelihood function. However, I have encountered an issue with ar1 potentially producing negative values, resulting in negative alphas. How can I address this error?
priors = {
"coefs": {"mu": [0.0274, 0.9839], "sigma": [0.1, 0.1], "size": 2},
"sigma": 10,
"init": {"mu": 0.016267, "sigma": 0.014459, "size": 1},
}
with pm.Model() as AR:
pass
t_data = list(range(len(div_yield_numpy)))
AR.add_coord("obs_id", t_data, mutable=True)
with AR:
t = pm.MutableData("t", t_data, dims="obs_id")
y = pm.MutableData("y", div_yield_numpy, dims="obs_id")
coefs = pm.Beta("coefs", priors["coefs"]["mu"], priors["coefs"]["sigma"])
sigma = pm.HalfNormal("sigma",
priors["sigma"]
)
init = pm.Beta.dist(
priors["init"]["mu"], priors["init"]["sigma"], size=priors["init"]["size"]
)
ar1 = pm.AR(
"ar1",
coefs,
sigma=sigma,
init_dist=init,
constant=True,
steps=t.shape[0] - (priors["coefs"]["size"] - 1),
dims="obs_id",
)
# The Likelihood
outcome = pm.Beta("likelihood",
mu=ar1,
sigma=sigma,
observed=y,
dims="obs_id"
)
idata_ar = pm.sample_prior_predictive(1000)