# Mixed models: predict random intercept with partial data

I have a dataset with growth data for teens between 12 and 18 years old, where I want to predict throwing speed for all ages using a couple of other predictors. These predictors have been collected in the dataset for all participants at all times, but in practice they are time dependent and thus cannot be taken into account for future real-life prediction. I have longitudinal data on speed, height, strength and weight for these kids ranged 12 to 18 (all of which change (and grow) over time for each individual), and although unfortunately few measurements for the ages below 13, I have many measurements for the ages 13-18.

As per request a short overview of the data:

> str(dat)
'data.frame':   390 obs. of  12 variables:
$PPnumber : Factor w/ 126 levels "","FB_001","FB_002",..: 2 2 2 2 2 3 3 3 4 4 ...$ Height          : num  170 172 174 NA 176 ...
$ageyrs : num 13.6 14.2 14.6 15.1 15.6 ...$ weight          : num  64.1 69.1 74.2 NA 74.3 73.2 77.6 78.5 49 49.8 ...
$AverageBallSpeed: num 61.6 68 65.8 71.2 71.4 ...$ F_ER_DA         : int  102 128 138 126 154 185 150 186 115 103 ...
etc

However due to the fact that the study only lasted 3 years I have no data from 12 all the way up to 18, but I had hoped that multilevel or mixed effects modelling would overcome this limitation, as it also uses the group-level data when predicting for the individual. A workaround for using the time-dependent variables might be to include the other variables in the intercept;

$$\begin{array}{l} Y_{ij} &=& \beta_{0j} + \beta_{2}a_{ij} + \beta_{3}a_{ij}^2 + \delta_{ij},\label{eq:intcurve} \\ \beta_{0j} &=& \gamma_{00} + \boldsymbol{X_{1j}}^T\boldsymbol{\beta_{1j}} + \varepsilon_{0j}, \nonumber \end{array}$$

(Where $$Y_{ij}$$ is the speed I'm trying to predict and $$a_{ij}$$ the age at point $$i$$ and participant $$j$$, $$\boldsymbol{X_{0j}}^T$$ would be the other predictors such as height and strength at measurement 1). Although here only the first measurement would be used, I woud like to be able to use the first $$n$$ measurements to compute the random intercept, and then disregard these variables and plot a prediction over time of the speed.

I have two questions regarding this method:

1. Is this a valid way to define a multilevel/mixed effects model? I have little experience with these models and although it seems fine to me, perhaps this is not the best "workaround" to apply. Would this same method also work for a random slope model?
2. If so, is there a method for applying this in lme? I've tried the following:

MLMfull <- lme(Speed ~ age + I(age^2)+ Height + weight + ..., random = ~ 1 | Participant)

but I believe this means that the other variables are taken into account for the later predictions as well, and I would like to be able to predict future speeds without knowing the height of the participant at a certain future age.

Edit: Although my initial questions have not been answered, I have gotten some helpful advice for my problems, for which my gratitude. I'll mark one of the answers for now, but if anyone can still answer my two questions above, I would be much obliged.

When you have time-varying covariates there are a couple of important things you need to consider.

1. Whether the covariate is exogenous or endogenous. An exogenous time-varying covariate $$x_i(t)$$ ($$i$$ denotes the subject and $$t$$ the time) satisfies the following condition: $$p\{x_i(t) \mid \mathcal H_i^X(t), \mathcal H_i^Y(t)\} = p\{x_i(t) \mid \mathcal H_i^X(t)\},$$ where $$\mathcal H_i^X(t) = \{x_i(t_{i1}), \ldots, x_i(t_{ik}); t_{ik} \leq t\}$$ denotes the history of all past covariate values up to $$t$$ and likewise $$\mathcal H_i^Y(t) = \{y_i(t_{i1}), \ldots, y_i(t_{ik}); t_{ik} \leq t\}$$ denotes the history of all past outcome values up to $$t$$, and $$p(\cdot)$$ denotes either a probability density or probability mass function depending on the nature of $$x_i(t)$$. In simple words, the covariate is exogenous when its current value only depends on its history. If this is not the case, and conditional on its history $$\mathcal H_i^X(t)$$ the covariate at $$t$$ still depends on past outcome values, then it is endogenous. If the covariate is exogenous, then including in a mixed model would provide you with valid results. However, if it is endogenous, then you need more advanced models, such as joint models or marginal structural models.

2. The functional form. Namely, if you simply include the covariate into your mixed model, you postulate a cross-sectional relationship, i.e., $$y_i(t) = \alpha x_i(t) + \ldots,$$ that is the outcome at time $$t$$ is only associated with the current value of the covariate at the same time point, with $$\alpha$$ denoting the coefficient that measures the strength of the association (the “$$\ldots$$” denote the rest of the stuff you have in your mixed model, i.e., other covariates, random effects and the error terms). However, it could be that the outcome at time $$t$$ also depends on past values of the covariate via a function $$f(\cdot)$$, $$y_i(t) = \alpha f\{\mathcal H_i^X(t)\} + \ldots,$$ e.g., the area under the trajectory of $$x_i(t)$$ up to $$t$$ or the slope of the trajectory up to $$t$$.

EDIT: If you do not have some covariates at a specific age, you could use an imputation approach. This would require to first fit a mixed model for the covariates themselves, then impute/predict from these models what will be their value at a specific age you are interested in, and then use these predictions into your model for $$y$$. To account for the variability in the predictions, you could repeat the process a number of times, obtaining each time another prediction from the asymptotic normal distribution of the predictive distribution.

• AFAIK, my covariates are all exogenous, and although I'm relatively sure about this, I don't know how to check this. But the slope of the trajectory is a good idea; players that increase steadily over time should have a higher predicted future value than those that don't. In that case, $\mathcal H_i^Y(t)$ would be a more valuable predictor than $\mathcal H_i^X(t)$ for any of my covariates $X$, although using it couldn't hurt. Would you know of any R packages that can deal with including the $\mathcal H_i^X(t)$ or $\mathcal H_i^Y(t)$, or should this be written as a new covariate for the model? Jun 28, 2019 at 8:48
• When you use a mixed model the history of the outcome $\mathcal H_i^Y(t)$ is automatically taken into account. With regard to the history of the covariates $\mathcal H_i^X(t)$ you will need to explicitly specify how it links to the outcome via function $f(\cdot)$. In an edit above, I provide a solution to the issue you mentioned of not having the covariates at a specific age. Jun 28, 2019 at 8:57
• Thank you for the edit, I had considered this but thought it perhaps too complicated because it will be used by people with little to no knowledge of mathematics. I will try it though. Just one more (perhaps dumb) question for the imputation: if I first fit a model for height depending on age, can I then use height as a predictor for e.g. weight even though height itself is predicted? Jun 28, 2019 at 10:04

I think I understand that your time-dependent variables are things like strength and height. Could you not use lagged values? So growth at time t depends on strength at time t-1? Or am I misunderstanding? You could also look at State Space (Kalman) modeling techniques that I believe can do things like your proposed equations.

• Yes, height is time-dependent as the participants would be 12 upon first measuring but we would like to predict for 18, so the participants grow a lot. I added it to the question for clarity. Lagged values might indeed work, but I would like to use all measured moments before time t, so it would work best if I only had one measurement. I don't know how to incorporate this in nlme, though, so I'll have to check if that works. I hadn't heard of Kalman modeling techniques but will check it out. Do you have a recommendation for papers/books dealing with this kind of modeling? Thanks anyway! Jun 27, 2019 at 15:44
• First, if speed is the rate of growth, I'd be careful of just using age and the square of age. Growth rates during adolescence are complicated. I'd try a spline. Second, if you are planning to use the first n measurements for predicting the random intercept, why not for speed, as well? Third, please clarify what variables are time varying. If your goal is to predict adult height for 12 year olds, then your model should have data from 12 year olds. Jun 27, 2019 at 16:37
• @PeterFlom Ah, yes, I am very aware that my model is a gross oversimplification of my data; indeed growth rates are complicated, but the issue is that this model will need to be used by non-mathematicians and with very limited new data, so I'm hesitant to complicate matters. I'll look into splines and see if that fits. As for predicting the speed: if there is a way to do it without needing them for future predictions, I'd like to use them like that as well. Admittedly I have looked at the problem while keeping the programming in mind, so I might've been too narrow minded in the modelling. Jun 27, 2019 at 17:15
• @PeterFlom As for the time varing variables: I have longitudinal data on speed, height, strength and weight for these kids ranged 12 to 18 (all of which change (and grow) over time for each individual), and although unfortunately few measurements for the ages below 13, I have many measurements for the ages 13-18. However due to the fact that the study only lasted 3 years I have no data from 12 all the way up to 18, but I had hoped that multilevel or mixed effects modelling would overcome this limitation, as it also uses the group-level data when predicting for the individual. Jun 27, 2019 at 17:22
• OK, but if your idea is to try to predict size at 18 from data at age 12, you can only use data at age 12 in your model, right? Jun 27, 2019 at 19:54