# Passenger arrival rate partial pooling model

Hello,

I am going to model a test track on which bus stops will be put. Since here is the community of pymc users, I thought that I can ask your opinion. I want to construct a hierarchical model for the passenger arrival rate for K major time ineterval for N minor time slots.

Assume that K1 between 13:00 and 14:00 PM, there are 5mins intervals in total of 12 time slots (N).

I am seeking answer for followings;
Arrival rate will be Poisson distribution, and prior conjugate is Gamma. Is this assumption suitable for this kind of problem?

The model above is for single bus stop. Can I extend the hierarchical model to multiple bus stop? Let’s say we have 3 bus stops, K time intervals, N minor time slots. I wonder how can combine all of these in one hierarchical model.

Luckily we don’t need to worry about conjugacy with any of the inference methods in pymc3, so you can just go ahead choosing whatever you like from that standpoint.

From what you are writing I think a generalized linear model with poission likelihood and log link would probably be a good way to get started. So something along the lines of this:

``````import pymc3 as pm
import theano.tensor as tt

with pm.Model() as model:
intercept = pm.Normal('intercept', mu=0, sd=10)
station_sd = pm.HalfStudentT('station_sd', sd=2, nu=3)
station_raw = pm.Normal('station_raw', mu=0, sd=1, shape=n_stations)
time_sd = pm.HalfStudentT('time_sd', sd=2, nu=3)
time_raw = pm.Normal('time_raw', mu=0, sd=1, shape=n_time)
time_station_sd = pm.HalfStudentT('time_station_sd', sd=2, nu=3)
time_station_raw = pm.Normal('time_station_raw', mu=0, sd=1, shape=(n_stations, n_time))

phi = (intercept
+ station_sd * station_raw[:, None]
+ time_sd * time_raw[None, :]
+ time_station_sd * time_station_raw)
pm.Poission('y', mu=tt.exp(phi), observed=data)
``````

where `data` is a `(n_stations, n_timepoints)` array with the observed number of passengers.