# Modelling longitudinal data where the effect of time varies in functional form between individuals

Context:

Imagine you had a longitudinal study which measured a dependent variable (DV) once a week for 20 weeks on 200 participants. Although I'm interested in general, typical DVs that I'm thinking of include job performance following hire or various well-being measures following a clinical psychology intervention.

I know that multilevel modelling can be used to model the relationship between time and the DV. You can also allow coefficients (e.g., intercepts, slopes, etc.) to vary between individuals and estimate the particular values for participants. But what if when visually inspecting the data you find that the relationship between time and the DV is any one of the following:

• different in functional form (perhaps some are linear and others are exponential or some have a discontinuity)
• different in error variance (some individuals are more volatile from one time point to the next)

Questions:

• What would be a good way to approach modelling data like this?
• Specifically, what approaches are good at identifying different types of relationships, and categorising individuals with regards to their type?
• What implementations exist in R for such analyses?
• Are there any references on how to do this: textbook or actual application?

I would suggest to look at the following three directions:

• longitudinal clustering: this is unsupervised, but you use k-means approach relying on the Calinsky criterion for assessing quality of the partitioning (package kml, and references included in the online help); so basically, it won't help identifying specific shape for individual time course, but just separate homogeneous evolution profile
• some kind of latent growth curve accounting for heteroscedasticity: my best guess would be to look at the extensive references around MPlus software, especially the FAQ and mailing. I've also heard of random effect multiplicative heteroscedastic model (try googling around those keywords). I find these papers (1, 2) interesting, but I didn't look at them in details. I will update with references on neuropsychological assessment once back to my office.
• functional PCA (fpca package) but it may be worth looking at functional data analysis

Other references (just browsed on the fly):

• Thanks. The idea of using a clustering procedure had occurred to me. I imagine the challenge would be to adequately capture and weight the possible individual-level curve features in a theoretically meaningful way. I'll have a look at see how it works in kml. Sep 17, 2010 at 9:08
• Well, it works pretty well although the interface is awful (and I know the guy who build it :) -- I used it two months ago for separating clinical groups based on individual profiles on developmental measurements (Brunet-Lézine).
– chl
Sep 17, 2010 at 9:12
• Here's another primary reference for FDA: psych.mcgill.ca/misc/fda Sep 17, 2010 at 12:02
• I found this introduction to FDA link by Ramsay (2008), particularly accessible gbi.agrsci.dk/~shd/public/FDA2008/FDA_Sage.pdf Sep 19, 2010 at 10:27

I'd recommend taking a look at a couple of papers by Heping Zhang using adaptive splines for modeling longitudinal data:

In addition, see the MASAL page for software including an R package.

It looks to me like Growth Mixture Models might have potential to allow you to examine your error variance. (PDF here). (I'm not sure what multiplicative heteroscedastic models are, but I will definitely have to check them out).

Latent group based trajectory models have become really popular lately in criminology. But many people simply take for granted that groups actually exist, and some astute research has pointed out that you will find groups even in random data. Also to note Nagin's group based modelling approach does not allow you to assess your error (and honestly I have never seen a model that would look anything like a discontinuity).

Although it would be difficult with 20 time points, for exploratory purposes creating simple heuristics to identify patterns could be helpful (e.g. always low or always high, coefficient of variation). I'm envisioning sparklines in a spreadsheet or parallel coordinates plots but I doubt they would be helpful (I honestly have not ever seen a parallel coordinate plot that is very enlightening).

Good luck

• Good point about latent groups. I've seen several applications of latent class analysis & cluster analysis where it seems to be just carving up a continuous variable int categories such low & high (jeromyanglim.blogspot.com/2009/09/…). However, I do have some individual-level longitudinal data which visually look like they are coming from categorically distinct data generating processes (e.g., always high, always low, gradual increasing, low-then-abrupt-increase, etc.) and within categories there is more continuous variation of parameters. Sep 19, 2010 at 9:22
• @Jeromy, I don't think the work I cited would discourage people from using such methods to identify latent groups. I would say the point of the work is that you can't use such methods to solely infer the existence of groups, because you will always find groups, even in random data. It is up to more subjective interpretation whether those groups you find are real or are simply artifacts of the method. You could identify some logical theories that generate such processes and then see if the groups identified fit within those theories. Sep 19, 2010 at 16:59

Four years after asking this question, I've learnt a few things, so perhaps I should add a few ideas.

I think Bayesian hierarchical modelling provides a flexible approach to this problem.

Software: Tools like jags, stan, WinBugs, and so on potentially combined with their respective R interface packages (e.g., rjags, rstan) make it easier to specify such models.

Varying within person error: Bayesian models make it easy to specify the within person error variance as a random factor that varies between people.

For example, you could model scores $y$ on participants $i=1,..., n$ at time points $j=1,...J$ as

$$y_{ij}\sim N(\mu_i, \sigma^2_i)$$ $$\mu_i = \gamma$$ $$\gamma \sim N(\mu_\gamma, \sigma^2_\gamma)$$ $$\sigma_i \sim \rm{Gamma}(\alpha, \beta)$$

Thus the standard deviation of each person might be modelled as a gamma distribution. I have found this to be an important parameter in many psychological domains where people vary in how much they vary over time.

Latent classes of curves: I have not explored this idea as much yet, but it is relatively straight forward to specify two or more possible data generating functions for each individual and then let the Bayesian model choose the most likely model for a given individual. Thus, you would typically get posterior probabilities for each individual regarding which functional form describes the individuals data.

As a sketch of an idea for a model, you could have something like the following:

$$y_{ij} \sim N(\mu_{ij}, \sigma^2)$$ $$\mu_{ij} = \gamma_i \lambda_{ij}^{(1)} + (1 - \gamma_i) \lambda_{ij}^{(2)}$$ $$\lambda_{ij}^{(1)} = \theta^{(1)}_{1i} + \theta^{(1)}_{2i} \exp(-\theta^{(1)}_{3i})$$ $$\lambda_{ij}^{(2)} =\theta^{(2)}_{1i} + \theta^{(2)}_{2i} x_{ij} + \theta^{(2)}_{3i} x^2_{ij}$$ $$\gamma_i = \rm{Bernoulli}(\pi_i)$$

Where $x_{ij}$ is time and $\lambda_{ij}^{(1)}$ represents expected values for a three parameter exponential model and $\lambda_{ij}^{(2)}$ represents expected values for a quadratic model. $\pi_i$ represents the probability that model will choose $\lambda_{ij}^{(1)}$.

• I've also been moving to the Bayesian framework, and have been reading on using Gaussian Processes for time series analysis of uncertain function forms. Still unclear how it can be applied to the case of hierarchical data (see my unanswered query here: groups.google.com/d/msg/stan-users/yjDWtMhxQQE/2TiYevy0ZwUJ) Sep 19, 2014 at 13:26

John Fox has a great appendix available on-line using nlme to look at longitudinal data. It may be useful for you:

http://cran.r-project.org/doc/contrib/Fox-Companion/appendix-mixed-models.pdf

There's a lot of great stuff there (and Fox' books are generally quite good!).

• Broken link. However, it's available from the author's web page here Sep 2, 2015 at 18:03