Hello PyMC devs and users,
I’m just getting more acquainted with PyMC3, so apologies if this is a silly issue.
I am working on a model whose essence can be described by the following model:
y[i,w] ~ Poisson(lam[i, w]) (Likelihood)
lam[i,w] = exp(gamma[i,w])
gamma[i, w] ~ GP(0, K(w, w'; params)) for each i, where K has size [w by w]
i can be interpreted as individuals, i \in {1, 2, ..., I}
w can be interpreted as weeks, w \in {1, 2, ..., W}
In other words, I have a inhomogenous poisson process, where the arrival rate term is a Gaussian Process. For each individual i, I want the same Gaussian Process to describe the joint density of gamma[i, :].
In the model context, I have written this using a for loop as follows:
cov_gamma = gamma_sigma * pm.gp.cov.ExpQuad(input_dim=1, ls=1)
gamma_gp = pm.gp.Latent(cov_func=cov_gamma)
#==== Loop over each individual to extract a draw (into an IxW matrix)
gamma_iw = tt.zeros(shape=(len(I), len(W)))
for i in range(0, len(I)):
gamma = gamma_gp.prior(f"gamma_{i}", X=W) # W is vector of weeks
tt.subtensor.set_subtensor(gamma_iw[i, :], gamma)
I believe this is correct. But compilation of this model is extremely slow as “I” increases. Seeing as the GP is compiled to pm.MultivariateNormal(), where we can adjust the shape, is there a more straightforward to specify this instead of the for loop?
I hope my question was clear, but I’m happy to clarify further if needed!