I have a time series that count the number of "type 1" events in a city, for each day. The serie contains a lot of zeros because type 1 events are rare (about 80% of counts are zeros).
I'm using a Poisson Model but I don't know how to handle temporal dependencies. For example, I know that there are some other events (let say "type 2") which will increase the probability of an event of type 1 in the current day and/or in the next days. The Poisson parameter is not constant over time.
Do you know a good R package to handle this and a good way to model this situation ?
Thanks
Best Answer
You can still do this in a generalized linear model framework (using glm
or glmnet
in R). A crude way of accounting for time would simply be to include it as a covariate with a model like
$$ log(lambda_i) = alpha t_i + beta^T x_i . $$
This of course has problems because it assumes a linear relationship between $t_i$ and $log(lambda_i)$, and if you feel that certain days have more of an impact than others you might include indicator variables for those days and give them their own coefficients.
Another approach might be to use a generalized additive model (the gam
package) instead, but the basic concept is the same.
Similar Posts:
- Solved – Am I breaking the assumptions of the Poisson distribution
- Solved – Relationship between λ (or μ) in Poisson and Exponential distribution
- Solved – Modeling a Poisson process with 10000 events per minute
- Solved – Calculate Expected Values in Poisson Distribution
- Solved – Modelling time-dependent rate using Bayesian statistics (pymc3)