I'm trying to specify a model for predicting lung cancer incidence based on a person's smoking history. Most studies simply use pack-years, a measure of the total cigarettes smoked in one's lifetime. I'd like to incorporate time weights into the calculation of pack-years, where the weights are estimated as part of the regression equation. What this adds is the ability to say, for example, that the effect of smoking a cigarette today is 3 times more influential than a cigarette smoked 10 years ago. I'm thinking of a Cox proportional hazards model (semi-parametric) like the one below, or maybe an accelerated failure time (parametric) model that might be more appropriate for prediction. How can I specify this model, preferably using an R package?
$\lambda(t|X_i) = \lambda_0(t)\exp(\beta_1{Age}_i + \beta_2{Gender}_i + \beta_3 WPY_{i})$
The hazard rate at time $t$ is a function of age, gender and the weighted pack-year covariate.
$WPY_i ~ \sim \sum_{j=1}^{m} \omega_j \space PY_{ij}$
Weighted pack-years are calculated as, summing over each previous month $m$, the number of pack-years smoked in that month $PY_{ij}$ multiplied by the weight for that month $\omega_j$. Note that month $m$ means "months since now", not the calendar month. I expect that the weights $w_j$ follow something like a Gamma distribution and collectively sum to 1.
I attempted this already by wrapping a Cox model inside of optim()
to get values of $\omega_j$ that maximize the likelihood of the observed data. However, I'm not sure that I'm setting that up correctly and there's probably a less hacky way. I'm thinking this is possible with Stan. Any ideas?