# Group level interaction or mixed effects model

I have a model where I expect the relationship of my independent variable of interest and the dependent variable to decrease over time (year in my case).

Now I have three approaches to measure such a heterogenous relationship.

1. Simple regression of the form with an interaction of x and t

y = x + x*t + t, where t is categorical (not continuous)

1. Multiple regressions for every t

y = x

1. A mixed model with time as the grouping indicator

y = x + (x|time)

I am working with R and the mixed model is estimated with lmer(). Now I somewhat understand that option 2 is not ideal because it is not appropriate to just compare the coefficients from models that were estimated independent of each other, especially if there are differing sample sizes for each period t.

Option 3 seems the most fancy. However, fanciness doesnt get me anywhere. So with mixed models I understand that if the grouping makes sense, I would expect the standard errors to be clustered a the year level. In other words, there could be autocorrelation between all individuals observed at t=i. And that would then be an advantage over option 1, because there the errors are assumed to be clustered at the individual level?

Is my assertion correct? My goal is not to see whether the interaction of x and t is significant, rather to capture the decreasing relationship. So, I have 6 time periods and my resulting coefficients for option 1 give me b(xt) at (t=1) = 0.8, b(xt) at (t=2) = 0.6, b(x*t) at (t=3) = 0.4 etc. Neither of the coefficients are significant by themselves, however, the variation in the coefficients is definitely downward and does not seem to be random.

Results are similar for options 2 and 3. I am farily satisfied with my results but I don't quite know how to assess the differences between the 3 options and which option has the least disadvantages.

Any ideas? I was not able to find anything in the literature. My book by Gelman and Hill, "Data analysis using regression and multilevel models" does say, that varying slopes by a group level indicator can be interpreted as an interaction. But what is it then, that makes multilevel/mixed models superior to option 1 and 2?

#--------

Edit (due to reply from mkt and Doctor Milt)

One example to illustrate the kind of effect I am aiming to measure:

Let's say Y = a country's GDP per capita and x is the savings rate. It is known that high saving rates are important especially when a country is in the process of economic catch-up growth. Meaning, (in Europe for example after World War 2) high saving rates were more important in the past than they are now. So a coefficient of x would have been higher in 1950 than in 1980 et.

• Could you provide a little more detail about what your variables are, and the nature of the expected decline over time? Also, there may be better options if you're willing to treat time as continuous, so it would help if you explained why you don't want to consider that.
– mkt
Commented Feb 21, 2023 at 11:01
• This seems like a natural setup for a GAM (generalised additive model), using a spline to capture the time-varying coefficient of x. With the mgcv package in R, you would specify your model as gam(y ~ s(time, by = x)). Commented Feb 21, 2023 at 11:20
• Sure. Let's say Y = a country's GDP per capita and x is the savings rate. It is known that high saving rates are important especially when a country is in the process of economic catch-up growth. Meaning, (in Europe for example after World War 2) high saving rates were more important in the past than they are now. So a coefficient of x would have been higher in 1950 than in 1980 et. Commented Feb 21, 2023 at 11:21
• @DoctorMilt, true I have considered that also. But only because I read about it somehwere. It would be one more option. Also varying-coefficient models would be an option. I just dont know of any of these approaches and for now I chose multilevel estimation as my main approach. Do you have any good sources, links or literature regarding GAMs? Commented Feb 21, 2023 at 11:26
– mkt
Commented Feb 21, 2023 at 20:34

Your example suggests that you are analyzing panel data in which the same individuals (or countries, or ...) are observed at a series of time points. Your models don't seem to take the intra-individual correlations into account. That's critical, if that's how your data are actually structured.

With respect to your 3 models, in reverse order:

Model 3 would allow for different intercepts, and different slopes with respect to x, among the time values. It would, however, simply force those estimates into Gaussian distributions without regard to the ordering of observations over time.

You have already noted the deficiency in Model 2.

Something based on Model 1 is called for. The interaction helps evaluate whether there is any evidence for differences in the associations of x with outcome across time.

With time as multi-level categorical, you can do a combined "chunk" test that evaluates all interaction terms at once (a likelihood-ratio test between models with and without the interaction, or a Wald test on all the interaction coefficients together). You then can evaluate whether there are specific differences among time points.

A continuous model of time might be preferable. A generalized additive model (GAM), as recommended in comments, is one way to proceed. A regression spline (a very simple type of GAM) might work well. The question will be how much complexity in terms of the interaction between (the function of) time and x to include in the model.

Frank Harrell's online notes discuss different approaches to modeling longitudinal data and ways to incorporate modeling with splines.

• thank you for your thorough answer. You gave me something to think about. I did consider likelihood ratio tests regarding the Multilevel models where I compare model without varying slopes to the one that allows for varying slopes. I feel all of the three options have their benefits and disadvantages. Including the GAM I have to do some more reading. I guess for the sake of transparency I should compute all models and show whether they results are similar. --> in a sense this would also work as a robustness check I guess. Commented Mar 1, 2023 at 10:18
• @tony13s a GAM can be used for flexible modeling of any continuous predictor in any of your options. I don't see that there is any advantage to option 2, due to the loss of power. Option 3 won't readily let you evaluate the time course of changes in slopes, as it forces the distribution of slopes to be Gaussian regardless of the actual time values. Given those significant limitations, I don't think that either of those options provides much of a "robustness check" for proper modeling under option 1.
– EdM
Commented Mar 1, 2023 at 14:41