# Plotting and presenting longitudinal data, options?

Hypothetical Scenario: A few continuous variables, each measured repeatedly at, say 12 time points, each with say, 150 observations. There are small fluctuations from one time point to another (i.e. change is not that smooth), but the variables are showing overall time-related changes.

Question: What are different options and their pros and cons in plotting and presenting change in such data? Would be excellent if example graphs/codes could be attached.

This is probably a very vague and general question, and I understand that it very much depends on what one wants to highlight, the kind of analyses conducted, the number of time points, the number of observations, etc. But it would be very helpful to have an idea how people usually plot their longitudinal data and what (nice) options are available. I'm particularly interested in hearing the options to highlight time-related changes integrated with individual differences (e.g. variability at each time point and variability in growth curve trajectories) in these changes.

For those interested, here is some randomly selected 100 observations from one segment of 12 time points to play with. Missings were coded as NA and data were structured wide.

• From a previous experience, we plotted means with SE as error bars over time, which was frowned upon by a reviewer who requested using SD instead. SDs were so large that actual change trajectories in means became barely visible (actually I still don't quite understand why SDs were preferred...). Plotting individual growth curves with means is messy; showing the means and variances of latent growth factors (slopes and intercepts) seem to lose a lot of raw information... Commented Apr 3, 2013 at 1:44
• I agree that SD vs. SE is potentially a pretty silly critique (absent any other justification). A good way to plot the original data is to make the lines very thin and semi-transparent, this allows one to see the distribution of the raw trajectories. Can you give an example of what you mean by "individual differences"? Is this a time-varying covariate - or are you just talking about varying individual growth trajectories? Commented Apr 3, 2013 at 12:40
• @DavidVandenbos I just added some sample data for people to play with. As dropbox only has https public links, R doesn't seem to read from the URL, so you'll probably have to download the file first... Commented Apr 4, 2013 at 0:05

Here's one idea for visualizing your data. Using a variation of small multiples, you could have two charts: one showing the variables' mean with a focus on a variable of interest (including SE or SD), with the second showing the focused variables individual observations.

The following chart shows three variables across 6 time periods, with 50 observations each. The shaded area indicates the SE of the focus variable, which is highlighted similarly in both charts.

This could be easily scaled up or down based upon your specific needs. It can also be interactive, with a drop-down selection of a variable, and the focus and observations changing to the new item of interest.

EDIT: Here's another example, using your sample data. This shows the mean and SE (disregarding the NA's, since I don't know how you'll handle the calcs).

These were done in Excel, so I have no idea what the equivalent R code would be, but someone else here probably does. To create this chart, you'll have to nudge Excel into doing what you want. For the sample data you provided, I:

1. Added four calculated rows: Mean, SE, Mean-SE, and 2*SE

2. Create a line chart with all of your observations as series across your time periods. Format to your taste (it's probably worth some VBA to format everything at once, instead of individually selecting all 150 series). Format the rest of this chart to your preferences.

3. Copy the chart, and paste it onto the same worksheet.

4. Using the copy, delete all the series and add the Mean-SE and 2*SE series.

5. Convert the chart type from Line Chart to Stacked Area Chart.

6. Format the bottom series (Mean-SE) to No Fill. This should create the appearance of the 2*SE series floating.

7. Add the Mean Series, and convert it to a Line Chart Type. This will cause it to appear in front of the 2*SE area series.

8. Format the Chart Area and Plot Area to No Fill.

9. Using Page Layout > Align > Snap to Grid align the two charts with the second chart on top.

While this looks pretty convoluted, it only takes 10-15 minutes to complete, which if you're like me is much less than trying to learn R.

• This is very neat, thanks! Mind sharing the codes? :-) Commented Apr 4, 2013 at 0:07
• Thanks. No code necessary, its just Excel. I'll add some info about the setup when I'm back at my computer.
– dav
Commented Apr 4, 2013 at 0:12
• Wow, @DavidVandenbos I would never have thought about placing two charts on top of each other! Thanks so much for your tip and for taking the time to explain! Commented Apr 6, 2013 at 1:25

One often overlooked problem with plotting/analyzing summary (e.g. mean) curves is how to deal with Phase Variation. In an extreme example, one could plot the mean of 2 sin curves that are 180 degrees out of phase. This would of course be a straight line, which clearly doesn't reflect anything interesting about the individual curves (expect perhaps that they are out of phase).

Thinking in terms of a latent growth curve model, estimated variances of the random growth factors do nothing to account for phase variation, which is one reason why overall model fit for latent growth curve models is often poor (and usually not even assessed in hierarchical linear models).

I know this isn't exactly what your question is about, but I'll go ahead and mention two ways to try and deal with this. The first is to expand a LGCM to a growth mixture model, where you can use latent group membership to try and capture differences in when the curves peak. Another idea is to use functional data analysis for curve registration. I can add more detail later if it would be helpful.

Regarding growth mixture models:

Your choice for the functional form with a latent growth curve model is somewhat limited. Depending on the number of time points available, you can do linear, polynomials, and linear splines. A less used option however is a "freed-loading" model, in which the factor loadings for a single "slope" factor are freely estimated, expect 2 of them, which are set to define the scale of the latent factor (this is nicely described in Bollen and Curran's book on LGCMs). You can estimate this model with as few as 5 time points. It comes in realy useful for non-monotonic, multi-modal curves.

One problem though is that this functional form is the same for every person...it assumed that they all peak and trough and the same points, and variation in the slope factor just describes how much they peak or trough relative to the mean. It does nothing for phase variation. By extending this to a mixture model, where the slope factor loadings are freely estimated for each latent class, you can have a model that captures any important differences in phase variation because they each get their own curves.

• Thank you! It is a really good point on phase variation and excellent example with sin curves. Could you enlighten on how growth mixture model helps? Commented Apr 6, 2013 at 1:50