Jeromy Anglim's Blog: Psychology and Statistics


Wednesday, November 26, 2008

Longitudinal Data with Varying Numbers of Time Points using SPSS

Context:
I recently chatted with a researcher who had data in the following format: around 20 participants; participants completed between 5 and 15 sessions, but some sessions involved missing data and sessions could be classified into one of five phases. For each session there were a few measurements. There were also a number of baseline measures. The challenge was how to make the most of the data file. The following were a few recommendations I made.
Converting to Long format:
  • Longitudinal data files should generally be converted from wide format (one row per participant) to long format (one row for each session by participant combination). SPSS provides some tools for doing this or it can be done using more manual copying and pasting approaches.
  • The Restructure tool in SPSS can be found using the menu Data - Restructure. See the UCLA tutorial.
  • The long format data file will have variables for participant id, session number, whether data was missing or not missing, phase of the session, and any variables recorded in the session.
  • By structuring the data file in the long format, time can be treated more flexibly. For example, the actual days after the first session can be recorded to explore the effect of varying times between sessions.
  • Long format also makes computations on session variables a lot easier. For example, if you recorded variable X and variable Y in each session and you want to create a variable that is X / (X+Y), you only need to do this once, rather than writing different compute functions for all possible sessions.
Aggregating:
  • Data can be aggregated up to the phase level or the participant level easily using the original long format data file.
  • SPSS provides the Aggregate tool under: Data - Aggregate. For more information see Google or Oakes Psych 319.
  • By using participant id as the break variable, you can get variables like average score on the session variables, or counts of the number of sessions. In this instance, data could also be aggregated up to the phase level, if that was of interest.
Merging:
  • In these circumstances it is generally useful to have a participant-level data file and a session-level data file. The participant data file stays in wide format but only includes information that does not change over time (i.e., base line measures, person conducting the session etc.). If you aggregate the session-level data in the long format to the participant-level, you will often want to merge it back in to the participant data file. This allows you to do such things as correlate the different measures.
  • SPSS provides a merge data file feature where you merge data based on a key that is common to both data files (i.e., the participant id is common to both the aggregate of the long format data file and the participant information data file). In this instance, the feature can be found under: Data - Merge Files - Add variables. Tutorials on this are just a quick Google Search away.
Exploring patterns
Repeated measures data such as this is multilevel data where observations are nested within participants. It can be very interesting to explore the patterns of the session variables over time to see the general patterns and how they may or may not vary between participants.

Singer and Willett
For a good introduction to exploring patterns of change, I recommend:
Even if you are not interested in the more technical issues of statistical modelling of such data structures, the first few chapters have a good overview of how to think about such data. It can be very useful to first explore patterns of change over time.

Robert Siegler
Robert S. Siegler also has some great articles about change in child development, which has relevance to other areas of psychology where you may be interested in change: He provides PDFs for some of his articles online. The following is a good first article: Lemaire, P., & Siegler, R. S. (1995). Four aspects of strategic change: Contributions to children's learning of multiplication. Journal of Experimental Psychology: General, 124, 83-97.