# gamma mixed model with offset and/or weights

I have some continuous positive data $Y_{ij}$ representing accumulated quantities, where $i$ denotes subject and $j$ a state. Patients are transitioning across states sequentially, but not all patients visit all states. Also, the assumption here is that $Y_{ij}$ were accumulated at a constant rate within each state $j$, but these rates are different across states. We have the times $t_{ij}$ where subjects spent in each state. We also have some other covariates, some time dependent, some not. The interest here is to estimate the mean rate conditional on state, as well as on values of the other covariates. This is different from estimating the mean $Y$ conditional on time, state and covariates.

I was thinking of fitting a generalized linear mixed model, with the following characteristics:

• time values $t_{ij}$ can be used as offset, so that rate can be estimated

• the model will be of the Gamma family with log link, for convenience for the offset (log of times will be used)

• the correlation between $Y_{ij}$ across $j$ values within $i$ will be expressed with one random effect expressing the random intercept per subject i
• states will be categorical variable (choosing one of them as baseline)

What I am not sure about is if I also need to use time as weights. I want to model the fact that $Y_{ij}$ for longer times should have higher “weight”, since the “rate” is estimated over a longer period of accumulation.

I was thinking of using glmer function in lme4 R package.

Any comment/suggestion would be greatly appreciated.

Suppose you estimate the amount rather than the rate.

If you really think that patients are accumulating "stuff" linearly with time during their stay in each state, then you should use an offset of $\log(t_{ij})$ in conjunction with a log link for the Gamma model (I usually recommend this in any case). Suppose the model is parameterized with an intercept $\beta_1$, $\beta_{2} \ldots \beta_{n}$ for the effects of being in a state other than the first, and $\beta_{n+1} \ldots \beta_{n+k}$ for the effects of $k$ other covariates. Then if an individual is in the $j$th state ($j>1$),

Then the expression

$$\eta_0 = \beta_1 + \beta_{j} + \sum_m \beta_{m+n} x_m$$

defines the linear predictor, i.e. the logarithm of the predicted rate at which "stuff" is accumulated for that individual. But we add the offset to this baseline linear predictor: $\eta=\eta_0+\log(t)$, so that the predicted amount of stuff is $\exp(\eta) = \exp(\eta_0) \cdot t = \textrm{predicted rate} \cdot t$.

If you add $\log(t)$ as an additional predictor rather than an offset, then you'll estimate one more parameter $\beta_{n+k+1}$, and your model will become $\exp(\eta_0 + \beta_{n+k+1} \log(t)) = \exp(\eta_0) t^{\beta_{n+k+1}}$, which will allow you to model non-linear accumulation (if $\beta_{n+k+1}<1$, stuff is accumulating slower than linearly/decelerating; if $\beta_{n+k+1}>1$, stuff is accumulating faster than linearly/accelerating)

• Thanks Ben, this is how of I thought of it exactly. I am glad you had similar thoughts. One thing I am not sure how to do (and if I have to) is to "weight" more observations with larger $t_{ij}$, since they would be more informative in the estimation of the rate. I remember reading that in a Poisson model, using time as offset or weight give the same analysis. But I am not sure if I need to explicitly use weights in the case of the gamma mixed model with offset. – user20780 Feb 2 '18 at 20:32