# Two-steps estimation in poisson model

I want to fitting the Poisson model like below

D_{x,t} \sim Poisson(m_{x,t}),\\ \log m_{x,t} = B_xK_t + b_{x}k_t ~. \qquad (1)

I have to implement a two-step structure for estimating the parameters.

1- parameters B_x and K_t are estimated using the following model.

d_{x,t} \sim Poisson(g_{x,t}),\\ \log g_{x,t} = B_xK_t .

2- the estimated values of \hat{B}_x and \hat{K}_t are substituted in Equation (1) and the other parameters (b_x , k_t) are estimated. Can I use codes like the following in the model block?

model {
for(x in 1:A){
for(t in 1:n){
dxt[x,t] ~ poisson(exp( B[x] * K[t] ));
Dxt[x,t] ~ poisson(exp( B[x] * K[t] + b[x] * k[t]));
}}
}


I can not estimate the parameters in one step and I must do it in two steps.

1 Like

What do you mean with this?

1 Like

I want to emphasize that the idea of doing work in one step is not possible for me.

How would it look doing it in one step? How in two steps? In three?

For example, if we want to do in one step:

model {
for(x in 1:A){
for(t in 1:n){
Dxt[x,t] ~ poisson(exp( B[x] * K[t] + b[x] * k[t]));
}}
}


But I want to first estimate B_x and K_t using

d_{x,t} \sim Poisson(g_{x,t}),\\ \log (g_{x,t}) = B_x K_t,

and then use their estimated values \hat{B}_x and \hat{K}_t as constant values in

D_{x,t} \sim Poisson(m_{x,t}),\\ \log (m_{x,t}) = \hat{B}_x \hat{K}_t + b_x k_t,

to estimate the other parameters b_x and k_t.

And why do you want the first parameters to be constant in the “second step”?

Because, without the two step strategy, to ensure convergence, further constraints may need to be imposed; for example, the parameters in the B_x , K_t and the b_x, k_t are all orthogonal to one another.

If you need further constraints (e.g. to get rid of “spurious” modes), maybe a better approach would be to encode them into the parameters in the stan model?

This e.g. should be possible in principle, but you may get dependence between the parameters.

3 Likes

Just to clarify a bit what I believe @Funko_Unko is aiming at:

You can definitely have multiple likelihood terms in a single model and there can be - in principle - almost any dependency structure among them. In practice, some models are problematic for Stan (and other samplers), but that’s a different question.

Also, you can use y ~ poisson_log(lambda) instead of y ~ poisson(exp(lambda)) for increased efficiency and numerical stability.

Best of luck with your model!

2 Likes

What results are you getting when you do the “one step” estimation?

1 Like

It is done very very slowly.

Hi,
I think we are missing a lot of background to be able to help you effectively. Could you share the full Stan model? Could you also share at least a subset of the data? What do the data represent? How big is the dataset? What is the scientific/real-world question you are trying to answer?

It is generally our experience that when a model is very slow, it is often because there is some problem with the model, so before thinking about doing any sort of two step process, I would check if the model makes sense for your problem.

It is also usually better for us if instead of saying something is “not possible” to be specific and say why do you believe it is not possible, what did you try? What did you expect to happen? And what did happen instead?

Best of luck with your model!