Consider some individuals that are followed during a period $T = 1$ (the same for all individuals). The individual indexed by $i$ have $n_i \ge 0$ events, at times $t_{i1}, t_{i2}, \dots, t_{in_i}$. There is a vector $X_{i}$ of covariates that influence the probability of event occurrence.
A simple model is a Poisson regression: $n_i \sim \mathcal P(\lambda_i)$ with $E(n_i) = \lambda_i = \lambda_0 e^{X_i \beta}$.
If after estimating the coefficients, I want some kind of individual effect, I could consider for example response residuals $n_i - \widehat{\lambda_i} = n_i - \widehat{\lambda_0} e^{X_i \widehat{\beta}}$.
Now, what's happening is that $X_i$ depends on $t$, and moreover the baseline risk $\lambda_0$ might as well depend on $t$. I can consider a counting process with intensity $\lambda_i(t) = \lambda_0(t) e^{X_i(t) \beta}$.
Do you think it’s the way to go? Can I fit this model (and, if possible, obtain response residuals or anything that can serve as a proxy of an individual effect) with a classical R package like survival
?
All your thoughts are welcome.