Time Varying Overdispersed Poisson Process

Ah whoops I just edited my code, k=a, theta=b, and observed was meant to be df.y. Just ran the code and it works, thank you!

I have a follow up question if you’re up for it: I just started running it and its incredibly slow (3-4+ hours for sampling). Do you have any recommendations after seeing this code on how to improve it? I had originally figured this method would be a little faster to sample than using a linear model with an indexed categorical variables since it leverages fourier series and therefore less degrees of freedom, but maybe not