5
$\begingroup$

In a mixed effects regression model, it seems pretty standard that not all data has to be available at the same level. For example, some variables may be available at both country and province levels, while others are only available at the country level.

For example, suppose we have a model where the response variable $Y$ is predicted by $X_1$, $X_2$, and $X_3$. Here, $X_1$ and $X_2$ are available at both country and province levels, but $X_3$ is only available at the country level.

We should be able to write the model like this:

$$ Y_{ijk} = \beta_0 + \beta_1X_{1ijk} + \beta_2X_{2ijk} + \beta_3X_{3k} + u_{0k} + u_{1k}X_{1ijk} + u_{2k}X_{2ijk} + v_{0jk} + \epsilon_{ijk} $$

Where:

  • $Y_{ijk}$ represents the response for observation $i$ in province $j$ of country $k$
  • $\beta_0$ is the overall intercept
  • $\beta_1$, $\beta_2$, and $\beta_3$ are the fixed effects coefficients
  • $X_{1ijk}$ and $X_{2ijk}$ are predictors available at both country and province levels
  • $X_{3k}$ is a predictor only available at the country level
  • $u_{0k}$, $u_{1k}$, and $u_{2k}$ are random effects for the intercept and slopes at the country level
  • $v_{0jk}$ is the random effect for the intercept at the province level
  • $\epsilon_{ijk}$ is the residual error

If we use the general practice to write random effects based on the normal distribution:

$$ \begin{pmatrix} u_{0k} \\ u_{1k} \\ u_{2k} \end{pmatrix} \sim N\left(\begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix}, \begin{pmatrix} \sigma_{u0}^2 & \sigma_{u01} & \sigma_{u02} \\ \sigma_{u01} & \sigma_{u1}^2 & \sigma_{u12} \\ \sigma_{u02} & \sigma_{u12} & \sigma_{u2}^2 \end{pmatrix}\right) $$

$$ v_{0jk} \sim N(0, \sigma_{v0}^2) $$

$$ \epsilon_{ijk} \sim N(0, \sigma_{\epsilon}^2) $$

In the end, it seems this model has no problem with some variables ($X_1$ and $X_2$) are measured at both country and province levels, while others ($X_3$) are only available at the country level. The random effects $u_{0k}$, $u_{1k}$, and $u_{2k}$ capture country-level variations, while $v_{0jk}$ accounts for province-level variations within countries.


I am wondering - can the same logic be extended to Longitudinal Regression Models?

A longitudinal model and a mixed effects model are modelled very similarly. Just as a mixed effects model can allow for some variables to be collected on only higher level vs on both higher/lower levels, does this mean that a longitudinal model can still work if some of the variables are collected monthly and some of the variables are collected weekly? Or does this analogy not apply here?

For example, suppose I have longitudinal data:

  • $i$ = index for individual subjects
  • $t$ = index for time points (weeks)
  • $m$ = index for months

I wrote the model:

$$ Y_{it} = \beta_0 + \beta_1X_{it} + \beta_2Z_{m(t)} + \beta_3t + u_i + v_{m(t)} + \epsilon_{it} $$

Where:

  • $Y_{it}$ is the outcome variable for subject $i$ at week $t$

  • $X_{it}$ is a time-varying predictor measured weekly

  • $Z_{m(t)}$ is a time-varying predictor measured monthly

  • $t$ is the time variable (in weeks)

  • $\beta_0, \beta_1, \beta_2, \beta_3$ are fixed effects coefficients

  • $u_i$ is the random effect for subject $i$

  • $v_{m(t)}$ is the random effect for month $m$ corresponding to week $t$

  • $\epsilon_{it}$ is the residual error term

  • Random effects: $ u_i \sim N(0, \sigma_u^2) $, $ v_{m(t)} \sim N(0, \sigma_v^2) $, $ \epsilon_{it} \sim N(0, \sigma_\epsilon^2) $

In this kind of situation, (first option) I would have usually just aggregated all data at the less frequent time scale (i.e. monthly level in this case). (second option) The only other thing I could do is to leave the data at the weekly scale and paste the same monthly data across all weeks in the same month, e.g. subject 1 (month 1 = 6, week 1= 2.1), subject 1 (month 1 = 6, week 2= 5.3), subject 1 (month 1 = 6, week 3= 6.8), subject 1 (month 1 = 6, week 4= 0.3). However, I am not sure if the second option is appropriate, as it might perhaps violate some statistical assumptions or create excessive multicollinearity.

Is this OK?

$\endgroup$

3 Answers 3

1
+50
$\begingroup$

I believe your question relates to two things, and which one depends on whether the weekly and monthly observations are of the same thing or not. First, it is common to create variables at higher levels that are aggregates of information at the level below. For example, in Raudenbush and Bryk (2002), they create a mean level SES per school for a child simply by averaging all the child-level SES data within a particular school. This enables testing hypotheses about how a school's mean SES relates to it's mean achievement, as well as asking how a child's SES (school-mean centered) relates to his or her achievement.

Second, time-varying covariates are perfectly fine in longitudinal modeling as you probably know (e.g., consult p.180 and 237-245 of Raudenbush and Bryk). The trick here is that you've got observations nested twice within students. So you potentially have a 3-level model, which is also fine. On the lowest level (person-month-week), you'd have the weekly outcome along with the weekly covariate, and residual error:

$$ Y_{itm} = \pi_{0tm} + \pi_{1tm}week_{itm} + \pi_{2tm}X_{1tm} + e_{itm} $$

Then at the person-month level you'd have at a minimum: $$ \pi_{0tm} = \beta_{00m} + \beta_{01m}Z_{01m} + r_{0tm} $$

Edit: you may also need a "month" variable above

Finally at the person level, at a minimum:

$$ \beta_{00m} = \gamma_{000} + u_{00m} $$

Which I believe is equivalent to the combined model that you wrote, albeit in the R&B notation (your $\beta_{0}$ becomes $\gamma_{000}$ and you've got the different notation for 3 random effects). In the later case, you're not aggregating at all, you're using all of your information and allowing it to have an effect at the level it should.

$\endgroup$
1
  • $\begingroup$ Just a quick note, that it occurred to me that you may also need a "month" variable at level-2. I suppose you could try it either way. It will obviously be almost nearly collinear with the week variable. lme4 will know what level the month observations are on so it may be superfluous but just noting the fact that it might need to be there $\endgroup$
    – Rick Hass
    Commented Dec 4 at 14:38
2
$\begingroup$

It can be reasonable to apply mixed/hierarchical/multilevel models for longitudinal data, and indeed, the different variables can exist at different level of analysis. Pulling things at the more aggregate level will generally lead to loss of information, thus presumably to lower power, but also to interpretation difficulties (e.g. sign swaps, Simpson's paradox). If the phenomenon you describe truly has a smaller unit of analysis, it is often "more correct" to choose this level of analysis (but it is indeed more complex).

However, I am not sure if the second option is appropriate, as it might perhaps violate some statistical assumptions or create excessive multicollinearity.

Perfect multicollinearity (and only perfect) could be a problem for some versions of linear regression. If you had that, you could have to change some fixed effects by random effects, as hierarchical Bayesian models can handle this type of multicollinearity. However, if your system is not perfectly collinear, then this is not a problem for running a regression analysis (the main problem is computational, and if it occurs, standard statistical software should indicate that your empirical covariance matrix is ill-conditioned).

For other statistical assumptions you wonder could be broken, they could for example concern the autocorrelation of residuals. If you expect residuals to be highly correlated, then adopting robust standard errors (easier) or a formal time series model like a moving average (harder) could be a solution. It is a substantive modeling assumption, and an analysis of the correlation residuals could help you sort whether a simple mixed model suffices or if you need to go for something more complex.

$\endgroup$
1
$\begingroup$

(first option) I would have usually just aggregated all data at the less frequent time scale (i.e. monthly level in this case).

You can do this for simply tasks, but aggregating loses information. Ideally, we do aggregation only after fitting a model or the model itself recognizes such aggregation constraints. There is a field called "hierarchical forecasting" https://robjhyndman.com/publications/hf_marketing.html and https://otexts.com/fpp3/hierarchical.html where you can borrow some ideas.

(second option) The only other thing I could do is to leave the data at the weekly scale and paste the same monthly data across all weeks in the same month.

You can find the same practice in survival analysis where the data are arranged in a "counting process" https://cran.r-project.org/web/packages/survival/vignettes/timedep.pdf. I do not think interpolation and imputation to substantiate monthly data into weekly observations are good ideas in this case, because they introduce artificial variation and patterns. Your second model where monthly measurements are repeated for roughly every four weeks makes sense but could perhaps benefit from using a categorical variable "week in month". Then you can interpret the role of $Z$ as: when the monthly indicator $Z$ (measured in the beginning or at the end of a month) increases by one unit, the weekly outcome $Y$ increases by $\beta_2$ on average within the four weeks in the same month.

You need to understand the variable type and range of $Y$ to confirm whether linear models are a good choice. You should also look into lagged terms of $X$ and $Z$, and examine interactions among $X$, $Z$, week integers, seasonal indicators (month of year, quarter of year, ...), and their polynomials. Some assumption violations are caused by wrong model types and omitted variables, not mixing weekly predictors with monthly predictors.

Another thing to consider is seasonality in errors instead of random effects of time periods. You may need both monthly (every 4 weeks) and quarterly (every 13 weeks) seasonality in the error term. You need to look into mixed-effect models that allow correlated errors. For example, R packages {nlme} and {glmmTMB} allow such models, but the post popular {lme4} does not.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.