Individual differences that come from the model
Source:vignettes/articles/heterogeneity.qmd
heterogeneity.RmdIndividual differences estimated by a model, such as the variance of a random slope, are often read as differences between the people. They can also come from the model or from how the data are arranged. This article shows a case where people who are all the same appear to differ in how fast they change.
Data
Two hundred people are each observed twice, one year apart, starting at ages between 0 and 3. Everyone follows the same course, rising from 0 at age 0 towards 5, quickly at first and then more slowly. The measurements have a little error:
Plotted by occasion, as a two-wave study often is, people seem to differ: some change a lot between the two occasions and some hardly at all, and those who start lower change more.
ggplot(dat[dat$id <= 30, ], aes(occasion, y, group = id)) +
geom_point() + geom_line() + theme_bw()
Plotted by age, they all lie on one curve:
ggplot(dat[dat$id <= 30, ], aes(age, y, group = id)) +
geom_point() + geom_line() + theme_bw()
Two models
A linear growth model on the occasions has a starting level and a slope for each person. The measurement error is fixed to its true standard deviation, which two occasions per person cannot separate from the rest:
datocc <- data.frame(id = dat$id, time = dat$occasion, y = dat$y)
mlinear <- ctModel(type = 'ct',
manifestNames = 'y', latentNames = 'eta',
LAMBDA = 1, DRIFT = 0, DIFFUSION = 0, CINT = 'slope',
MANIFESTMEANS = 0, MANIFESTVAR = 0.1)
flinear <- ctFit(datocc, mlinear, cores = 2)
summary(flinear)$popsd
#> mean sd 2.5% 50% 97.5% mode
#> T0m_eta 1.143 0.061 1.023 1.142 1.263 1.138
#> slope 0.729 0.040 0.649 0.728 0.809 0.726
summary(flinear)$rawpopcorr
#> mean sd 2.5% 50% 97.5% mode z
#> slope__T0m_eta -0.998 0.002 -1 -0.999 -0.992 -0.999 -502.866The slopes differ a lot between people, and they are almost perfectly negatively correlated with the starting levels: where a person starts predicts how fast they change.
A model on age, with time running from age 0 for everyone, describes the shape of the course instead. Its process has an auto effect, which slows the growth as the level rises. Each person gets a row at age 0 with nothing observed, so that the starting value refers to age 0 for everyone. The starting value and the intercept still vary over people:
datage <- data.frame(id = dat$id, time = dat$age, y = dat$y)
start <- data.frame(id = 1:n, time = 0, y = NA)
datage <- rbind(start, datage)
datage <- datage[order(datage$id, datage$time), ]
mdynamic <- ctModel(type = 'ct',
manifestNames = 'y', latentNames = 'eta',
LAMBDA = 1, CINT = 'cint', MANIFESTMEANS = 0, MANIFESTVAR = 0.1)
fdynamic <- ctFit(datage, mdynamic, cores = 2)
summary(fdynamic)$popmeans
#> mean sd 2.5% 50% 97.5% mode
#> T0m_eta -0.011 0.034 -0.077 -0.012 0.059 -0.011
#> drift_eta -1.001 0.013 -1.027 -1.000 -0.977 -1.001
#> diff_eta 0.040 NA NA NA NA 0.031
#> cint 5.007 0.051 4.905 5.004 5.107 5.006
summary(fdynamic)$popsd
#> mean sd 2.5% 50% 97.5% mode
#> T0m_eta 0.024 NA NA NA NA 0.024
#> cint 0.001 NA NA NA NA 0.001The auto effect and intercept are close to the -1 and 5 of the process, and almost no differences between people remain. Both models fit the same observations, so their log likelihoods can be compared:
The differences between people in the first model came from fitting a straight line to a curve, with each person observed on a different part of it.
What follows
An estimated random effect means the model needs it, which can be because the people differ, or because the model leaves something out that varies between them. Here that was age. The same happens when cohorts of different ages are pooled, or when the time scale of a study (occasions, weeks since enrolment) is not the one the process follows. A model with a time scale and a form of change closer to the process leaves less to explain by differences between people.