Leanpub Header

Skip to main content

Fixed, Random and Multilevel Models for Change

Separate Within and Between Variation and Model Change in Panel Data Using R

Separate how people differ from how they change, and model change in time with panel data in R. In this course, you will learn how to estimate fixed effects, random effects and hybrid models with plm, and how to build, compare and interpret multilevel models for change with lme4. By the end, you will have a clear sequence of models for your own longitudinal data, from the empty model to growth models with time-varying predictors and non-linear change.

Interested in this course? Show your support by saying what you'd like to pay for it!

$
PDF
EPUB
WEB
About

About

About the Course

Longitudinal data, or data collected multiple times from the same cases, makes it possible to study how people change in time and why some people change more than others. This also brings a challenge. Each person is measured repeatedly, so the variation in the data has two sources: differences between people and changes within the same person.

This course will teach you the main regression-based models for this type of data and how to estimate them in R. You will start with fixed effects, random effects and hybrid models, which are useful when the main interest is in causal relationships. You will then learn the multilevel model for change. This model describes how people change in time, how much they differ in their starting point and rate of change, and what explains these differences.

The course focuses on the decisions you have to make when modelling change. These include which source of variation to model, whether to use fixed or random effects and how to code time. They also include how to add predictors that change in time and how to model change that is not linear.

The lectures and practicals use data from Understanding Society, a large UK household panel study, and all the models are estimated in R with the plm and lme4 packages. This way, the skills you learn transfer directly to your own research projects.

What You Will Learn

Within and between variation

Before modelling change, it helps to understand where the variation in longitudinal data comes from.

In this section, you will learn:

  • Why repeated measures are nested within people
  • The difference between within variation and between variation
  • The two ways of using panel data: as a quasi-experimental design to estimate causal relationships and as a way to explore change in time
  • Why time-constant variables can explain only the between variation, while time-varying variables have both types of variation

These concepts are the basis for every model in the course.

Fixed, random and hybrid models

When the main interest is in causal relationships and change in time is not the main focus, fixed and random effects models are a good place to start.

In this section, you will learn how to:

  • Estimate fixed effects (within) models, which control for all time-constant variables, measured or not
  • Estimate random effects models, which give both the within and the between variance and can include time-constant variables
  • Weigh the advantages and disadvantages of the two approaches, such as their assumptions and efficiency
  • Choose between them using the Hausman test
  • Estimate the hybrid (within-between) model, which gives the within and the between effect of the same predictor in one model
  • Run all of these models in R with the plm package

In the first practical, you will apply these models to explain log income.

The multilevel model for change

The multilevel model for change describes the average change in time and how much people differ from it.

In this section, you will learn how to:

  • Estimate the unconditional means model and split the variation into between and within parts
  • Calculate and interpret the intraclass correlation (ICC)
  • Estimate the unconditional growth model with random intercepts and random slopes using lme4
  • Interpret the correlation between the starting point and the rate of change
  • Explain differences in the starting point and in the rate of change with time-constant predictors
  • Compare models using likelihood ratio tests, AIC and BIC, and calculate the variance explained by a predictor
  • Read the results of a multilevel model for change in a published paper

These steps give you a sequence of models you can use to describe and explain change in your own data.

Extending the multilevel model for change

Many research questions involve predictors that change in time and trajectories that are not straight lines.

In this section, you will learn how to:

  • Include time-varying predictors and interact them with time
  • Separate a time-varying predictor into its between and within parts
  • Use lagged predictors and understand how they change the sample
  • Recode time so that the intercept refers to the start, the middle or the end of the study
  • Use the year of the interview, or age, as the time variable in place of the wave
  • Model non-linear change with polynomials or with time as a categorical variable, and decide between them
  • Build models in steps: empty models first, then unconditional change models, then predictors in blocks

With these extensions, you can adapt the multilevel model for change to the research questions and data in your own projects.

Learn by doing with real longitudinal data

The course combines videos, written explanations, quizzes, and hands-on practical exercises so you learn by applying the techniques directly. You will also gain access to a forum to ask questions related to the topics covered in the class.

The lectures use examples from Understanding Society (UKHLS), with life satisfaction as the main outcome. The three practical exercises use a synthetic version of Understanding Society, one of the largest longitudinal household surveys in the world. You will model change in log income over four waves, using sex, life satisfaction, the year of the interview and age.

Each practical includes:

  • Step-by-step exercises
  • Full solution code, as a PDF and as an R script
  • Detailed walkthrough videos

By the end of the course, you will have run a full sequence of fixed effects, random effects and multilevel models for change in R. You can then adapt the same code to your own panel data.

Who this course is for

This course is designed for researchers who want to model change with longitudinal and panel data in R, including:

  • PhD students working with longitudinal datasets
  • Social scientists using panel studies or cohort data
  • Data analysts working with repeated-measures data
  • Researchers who know linear regression and want to move to models for change
  • Researchers who need to choose between fixed effects, random effects and multilevel models for their own data

Prerequisites

You should already be comfortable with:

  • Basic R syntax
  • Working with data frames
  • Basic data manipulation and plotting with the tidyverse
  • Linear regression, including interactions

The course data is already cleaned and in long format. If you want to learn how to clean, merge and reshape panel data yourself, consider taking the course Master Longitudinal Data Wrangling using R.

If you are new to R, consider taking the course Introduction to R for Social Researchers, which provides the foundations needed to follow the workflows taught here.

What you will be able to do after this course

After completing the course, you will be able to:

  • Decide whether fixed effects, random effects, a hybrid model or a multilevel model for change fits your research question
  • Estimate fixed and random effects models in R and choose between them
  • Separate the within and between effects of a time-varying predictor
  • Estimate and interpret multilevel models for change with random intercepts and slopes
  • Explain differences in starting points and rates of change with time-constant and time-varying predictors
  • Model non-linear change and choose a time variable that fits your question
  • Compare models and report the variance they explain

You will also have a clear order for building models of change, from the empty model to models with predictors, that you can follow with your own panel data.

Share this course

Instructor

About the Instructor

Alexandru Cernat

Alexandru Cernat is a professor in Methodology and Social Data Science at the University of Manchester.

He has a PhD in survey methodology from the University of Essex and was a post-doc at the National Centre for Research Methods and the Cathie Marsh Institute.

His research and teaching focus on: survey methodology, longitudinal data, measurement error, latent variable modelling, new forms of data and missing data.

He is also the founder of longitudinalanalysis.com, a platform that helps researchers and analysts learn to collect, clean, and analyse longitudinal data.

You can find out more about him and his research at: alexcernat.com.

The Leanpub Podcast

Episode 267

An Interview with Alexandru Cernat

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub