# Interaction of Time-Varying Predictor and Time: How its inclusion changes the meaning of coefficients

I am interested in how an interaction between a time-varying-predictor and time changes the interpretation of other coefficients in a model.

I am modeling the effect of amphetamine-type substance (ATS) use on opioid use over time. Opioid use and ATS use are reported at the same time, therefore I can model ATS use as a time-varying predictor (see here). Here is the output from the first model. It is a longitudinal mixed effects model with two fixed predictors:

1. Time from Start of Treatment, a continuous variable measured in weeks (variable weeksFromStart)
2. Time-varying ATS use, a categorical variable measuring number of days respondents used ATS in the previous 28-day period (variable atsFactor). The three levels of this variable are no use (0 days used ATS in last 28 days), low use (0-12 days used ATS in last 28 days) and 'high' use (13-28 days used ATS in last 28 days). The no use category is the reference level of the categorical predictor.

The outcome variable in this model is opioid use (variable allOpioids) which measures number of days the respondent used any opioids in the previous 28-day period.

The model is a random slopes model, with weeksFromStart and participant id (variable pID) as the random factors.

This is the output from the model, performed using the lme() function from the nlme package in R.

#                    Value Std.Error   DF   t-value p-value
# (Intercept)     3.690054 0.2972079 1493 12.415736       0
# weeksFromStart -0.113363 0.0128773 1493 -8.803276       0
# atsFactorlow    3.376790 0.4386964 1493  7.697328       0
# atsFactorhigh   5.451483 0.9738413 1493  5.597917       0


The way I interpret this output is

1. At start of treatment (i.e. weeksFromStart = 0) respondents in the no use group had used opioids an average of 3.7 days in the previous 28 days.
2. Respondents in the no use group reduced their opioids an average of -0.11 days for each extra week they were being treated.
3. Averaged across all time points low use of ATS was associated with a 3.4-day increase in number of days of opioid use, compared with no use
4. Averaged across all time points, high use of ATS was associated with a 5.5-day increase in number of days of opioid use, compared with no use.

These interpretations seem quite straightforward.

After doing some research I realised I could also measure whether the time-varying effect of ATS use on opioid use also varies over time, but I am confused how to interpret the coefficients once I add the time-varying ATS Use x time interaction term to the model. Here is the output from the model, identical to the first except for the addition of the 'weeks of treatment x time-varying ATS Use' interaction term (variable weeksFromStart:atsFactor).

Here is the output

#                                  Value Std.Error   DF   t-value p-value
# (Intercept)                   3.384412 0.3060578 1491 11.058080   0.000
# weeksFromStart               -0.091329 0.0139118 1491 -6.564843   0.000
# atsFactorlow                  4.672925 0.5950429 1491  7.853090   0.000
# atsFactorhigh                 9.582114 1.3787037 1491  6.950089   0.000
# weeksFromStart:atsFactorlow  -0.100171 0.0322840 1491 -3.102806   0.002
# weeksFromStart:atsFactorhigh -0.322239 0.0770086 1491 -4.184448   0.000


Now my question is what do the atsFactorlow and atsFactorhigh coefficients mean, now that the interaction term has been added?

Are these coefficients now the effect of ATS Use (low or high) compared to no use at time = 0. i.e. are they a sort of intercept? They are certainly larger than the same coefficients in the previous model.

Any help much appreciated.

You are very close on the interpretations for the model without interactions. Starting with those, the only one you are a bit off on is the coefficient for weeksFromStart. You said:

Respondents in the no use group reduced their opioids an average of -0.11 days for each extra week they were being treated.

The weeks coefficient is telling you about the average opiod use decrease for each additional unit of weeks. It is not specifically for any group, it is a weighted average (more or less) across all three groups. This is because you are not interacting weeks with group in the first model. In a regression model without interactions, only the intercept is conditional on the other predictors being at a value of 0.

On the other hand, in your second model you add these interactions, and the results you presented are:

#                                  Value Std.Error   DF   t-value p-value
# (Intercept)                   3.384412 0.3060578 1491 11.058080   0.000
# weeksFromStart               -0.091329 0.0139118 1491 -6.564843   0.000
# atsFactorlow                  4.672925 0.5950429 1491  7.853090   0.000
# atsFactorhigh                 9.582114 1.3787037 1491  6.950089   0.000
# weeksFromStart:atsFactorlow  -0.100171 0.0322840 1491 -3.102806   0.002
# weeksFromStart:atsFactorhigh -0.322239 0.0770086 1491 -4.184448   0.000


You are correct that asFactorlow is the mean difference between this category and the referent at weeks==0, and similarly for the asFactorhigh coefficient, which is the difference between this group and the referent at weeks==0. The interaction tells you how much opiod use decreases for asFactorlow (vs the referent) for each additional unit of weeks. Whereas the interaction for atsFactorhigh tells you how much opiod use decreases for each additional week for this group relative to the referent.

I would suggest that you plot these results using the ggeffects() package and its ggpredict()%>%plot() function. These will allow you to see how the three groups are changing across weeks.

• Thank you @Erik Ruzek for that reminder about the meaning of non-intercept coefficients in a no-interaction model. I think I've been doing panel data with several groups for so long now I hardly ever use models without interactions. Thank you for the suggestion concerning how to graph this model. From what I have read I graphing these models is quite tough compared to their time-invariant cousins (where one can simply plot predicted trajectories for each group). I will investigate the ggeffects() package and will no doubt visit Stack Overflow with questions about that. Dec 18, 2019 at 1:05