I’m trying to build a model (on synthetic data for now) based on Poisson observations with a latent Gaussian process as the parameter. I can get this model working nicely:
with pm.Model() as period_trend_model:
period_ls = pm.Exponential('period_ls', lam=1.0)
period_cov = pm.gp.cov.Periodic(1, period=50, ls=period_ls)
trend_ls = pm.Exponential('trend_ls', lam=0.1)
trend_cov = pm.gp.cov.ExpQuad(1, ls=trend_ls)
gp = pm.gp.Latent(cov_func=period_cov*trend_cov)
f = gp.prior("f", X=x[:, None])
lam = pm.Deterministic("lam", pm.math.exp(f))
y = pm.Poisson('y', mu=lam, observed=y_obs)
With NUTS it infers the original function quite nicely.
When I try to extend this model to a “mixed effects” type model where there are multiple subjects, with individual multipliers, I run into problems. This is the model:
with pm.Model() as mixed_model:
period_ls = pm.Exponential('period_ls', lam=1.0)
period_cov = pm.gp.cov.Periodic(1, period=50, ls=period_ls)
trend_ls = pm.Exponential('trend_ls', lam=0.1)
trend_cov = pm.gp.cov.ExpQuad(1, ls=trend_ls)
gp = pm.gp.Latent(cov_func=period_cov*trend_cov)
f = gp.prior("f", X=X0[:, None])
base_lam = pm.Deterministic("base_lam", pm.math.exp(f))
alpha = pm.Exponential('alpha', lam=0.1)
beta = pm.Exponential('beta', lam=0.1)
individual_lam = pm.Gamma('individual_lam', alpha=alpha, beta=beta, shape=(1, n_individuals))
y = pm.Poisson('y', mu=T.dot(base_lam[:, None], individual_lam), observed=y_obs2.T)
I find that with both NUTS and ADVI, the samples of the Gaussian process are only changed in “lock step”, yielding these posterior samples (the dark line is the original function):
Can anyone suggest why this is happening? Thanks!