5
$\begingroup$

I fitted a linear mixed effects model using nlme package for aids dataset.

Fig. AIDS dataset in R, CD4 is the CD4 cell count, obstime is the time of observation, and patient is the patient id

Here, CD4 is the CD4 cell count, obstime is the time of observation, and patient is the patient id.

My linear mixed effects model looks like this:

lmeFIT <- lme(CD4 ~ obstime, random = ~ 1|patient, data=aids_train)

I have split my dataset into training and testing set where, my testing set consists of data from 2 subjects and training set consists of data from the remaining subjects. The model shown above, fits random intercepts for different patients in the training dataset. Now, my questions are

  1. Once the model has been fitted, how exactly does mixed effects model predict outputs for new patient ids in my testing dataset?
  2. All the examples I have seen online show that using mixed effects models we can plot fitted lines with different intercepts for each subject in the training dataset. However, how do we know what the intercept would be for the new dataset in the testing dataset? What is the mathematical explanation for that?
$\endgroup$

2 Answers 2

7
$\begingroup$

Provided that you have at least one data point for the new patient, you can calculate individualized (dynamic) predictions.

In particular, say that $y_j^o$ denotes the observed outcome data for the new patient $j$, then you can first obtain an estimate, say $b_j^*$ of his/her random effects from the posterior distribution $[b_j \mid y_j^o, \theta]$, where $\theta$ denotes the model parameters. For example, $b_j^*$ is the mean of this posterior distribution. Given this estimate of his/her random effects, you calculate predictions using $x_j(t) \beta + z_j(t) b_j^*$, where $x_j(t)$ and $z_j(t)$ denote the design matrices for the fixed and random effects at the (future) time points of interest, and $\beta$ denotes the fixed effects. Standard errors for these predictions can be obtained using a Monte Carlo scheme.

For models fitted by lme() you can obtain these predictions using function IndvPred_lme() from package JMbayes. If you have categorical longitudinal data, you can obtain the same type of individualized predictions using the predict() method for models fitted by the mixed_model() function of the GLMMadaptive package; for more info on the latter, you can also check the vignette.

$\endgroup$
6
  • $\begingroup$ This makes sense. So @Dimitris Rizopolous, is this the scheme you use in your JM package for dynamic predictions of longitudinal responses? And then use those predicted values in the joint model to predict survival probablities? Is there a simple step-by-step guide for JM model fitting and dynamic predictions? $\endgroup$
    – rish
    Sep 19, 2018 at 12:38
  • $\begingroup$ You can find material in my website drizopoulos.com $\endgroup$ Sep 19, 2018 at 13:05
  • $\begingroup$ Thanks a lot @Dimitris Rizopolous.... are there python equivalent packages for these (JMbayes and GLMMadaptive)? $\endgroup$
    – rish
    Sep 19, 2018 at 21:05
  • $\begingroup$ As far as I know no. $\endgroup$ Sep 20, 2018 at 0:52
  • $\begingroup$ @DimitrisRizopoulos Is there are similar solution to lmer that you are aware? $\endgroup$
    – Sapiens
    Sep 10, 2020 at 13:30
4
$\begingroup$

The random intercepts for the subjects represent deviations from a mean population-level response. When predicting for a new subject, the fitted random effects are not helpful; this is because there is no way of knowing a priori how that subject's pattern deviates from the population-level response. Instead, the best prediction for any new subject will be the population response by itself.

EDIT: There's no contradiction between the two answers here. @DimitrisRizopoulos makes the assumption that you have some information about the new patient i.e. at least one measurement. In contrast, I am making the assumption that you have no measurements of the new patient - in this case, the population response is the best prediction for any new patient.

$\endgroup$
6
  • $\begingroup$ So would it be correct to assume that basically mixed effects models are only useful for analyzing training dataset and for testing dataset it reduces to just a linear model? $\endgroup$
    – rish
    Sep 18, 2018 at 21:25
  • $\begingroup$ @rishrish I'm not entirely sure what you mean. But it's important to note that the population-level response need not be identical to that of a model with fixed effects only. Think about a case where subjects have different numbers of measurements. A model with fixed effects only would have its overall pattern biased towards the pattern shown in the overrepresented subjects. Introducing the random effect should account for this bias and lead to a different population-level pattern - one that makes is more accurate in predicting values for new subjects. $\endgroup$
    – mkt
    Sep 18, 2018 at 21:30
  • $\begingroup$ @rishrish Sure thing, happy to help! $\endgroup$
    – mkt
    Sep 18, 2018 at 21:38
  • $\begingroup$ i think prof. Dimitris Rizopolous's answer seems more relevant. Have a look.. $\endgroup$
    – rish
    Sep 19, 2018 at 12:33
  • 1
    $\begingroup$ I'm not aware of any inaccuracy in the answer, but would be happy to be corrected. $\endgroup$
    – mkt
    Dec 7, 2018 at 8:31

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.