Longitudinal Data Analysis Using R

A Growth Curve Modeling Compendium

A pedagogical compendium on latent growth curve modeling in R, developed from the NTNU Quantitative Methods Seminar Series in Psychology workshop “Longitudinal Data Analysis using Mplus and R” (December 2023).

Author

Frederick Anyan

Published

February 2026

Preface

Licence and how to cite

This compendium is intended for open use. The following conditions apply.

  1. This compendium is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0). You may share and adapt the text and the R code for non-commercial purposes if you give appropriate credit, say what you changed, and share your version under the same licence.
  2. Please cite the compendium whenever you use its text, figures, tables, or code in your own work. A suggested citation is given below.
  3. The data file data.csv contains artificial data and is not covered by this licence. It is included so that the examples can be reproduced. Please do not use it for other purposes without permission.
  4. The compendium is provided as it is, without any warranty. Please check the code and the results against your own data.

CC BY-NC-SA 4.0 licence badge

How to cite

Anyan, F. (2026). Longitudinal data analysis using R: A growth curve modeling compendium [Open educational resource]. https://frederickanyan.com/books/compendium/

Photo of Frederick Anyan

Contact

Frederick Anyan, Associate Professor of Quantitative Research Methods, NTNU

Email: frederick.anyan@ntnu.no

Website: frederickanyan.com

This compendium grew out of a workshop in the NTNU Quantitative Methods Seminar Series in Psychology on 1 December 2023, Longitudinal Data Analysis using Mplus and R. In the workshop we went through a sequence of latent growth curve models, one dataset, and one set of R scripts written with the lavaan package. The present compendium takes the R part of that workshop and writes it out in full, so that you can work through it alone and at your own pace.

For Mplus users

The workshop also used Mplus. The Mplus syntax and output for each model are in the Appendix: Mplus files, for readers who work in Mplus. The R chapters can be followed without them.

The compendium keeps the order of the workshop. We start with the practical steps before any model is fitted. Then we move from the no growth model to the linear and quadratic models, and from there to piecewise (spline) models, time-varying and time-invariant covariates, a distal outcome, multigroup models, and finally parallel and sequential growth processes. Each model chapter follows the same plan. We ask why the model is needed, describe the idea in plain language, look at a concrete example from the dataset, write the model formally, fit it in R, read the output, interpret it, and say what the model can and cannot tell us. The path diagrams and result slides in the chapters are taken from the workshop slides. They show estimates from Mplus. The numbers that are discussed in the text come from the R output.

  • The models are the workshop models. The lavaan syntax is the syntax of the workshop. Where I added something that was not part of the workshop, for example a sensitivity analysis with full information maximum likelihood, the text says so clearly.
  • The code is live. Every R chunk is run when the compendium is built. Most numbers in the text are computed in the chunks, so you can reproduce them with the data file that comes with the compendium. The few values that are typed in were checked against the output.
  • Fit is reported as it is. Several of the models do not fit the data well, and a few produce warnings from lavaan. I report these results and explain what they mean. The examples are there to teach the method. They are not substantive findings.
  • The default missing data handling is listwise deletion. The workshop code uses the default settings of growth(), and so the number of participants in the models is smaller than in the full data file. 1  Practical preliminaries before fitting growth models explains this and the chapters report the number of participants used in each model.
  • The data are artificial. The dataset that comes with the compendium is not real. It does not contain observations from real participants, and the results are not findings about real people. The data are there only so that the examples can be run and the models can be learned.
  • I have re-used and adapted parts of my own open access articles and workshop materials in this compendium. I have not put these passages in quotation marks.

The compendium is written for readers who know regression and the basics of structural equation modeling, and who want to learn how growth curve models work in practice. You will learn most if you run the code while you read.

Frederick Anyan
NTNU