Modeling Repeated Measures or Longitudinal Data
Example: Annual Assessment of Renal Function in Hypertensive Patients
UNITNO YEAR AGE SCr EGFR PSV
000-79-25 0 75.8 1.0 77.3 1.62
000-79-25 1 76.9 1.1 69.0 1.62
000-79-25 2 . . . .
000-79-25 3 78.3 1.0 76.8 1.62
000-79-25 4 79.4 1.4 51.9 1.62
001-00-05 0 83.4 1.4 38.1 1.20
001-00-05 1 84.0 1.6 32.6 1.20
001-00-05 2 85.4 2.1 23.8 1.20
001-00-05 3 86.4 1.8 28.3 1.20
001-00-05 4 87.4 1.3 41.1 1.20
responses for each subject are vectors
typical for some time points to be missed
Example: Annual Assessment of Renal Function in Hypertensive Patients
i
70.063.557.247.842.6
Y
Mean EGFR by Year
May want to examine:• Change in renal function over time• Effect of covariates on renal function• Interactions between covariates and time (i.e. do covariate effects differ over time)
Analysis must account for the correlation between observations taken from the same subject.
Are the observations correlated in our renal function example?
Pearson Correlation Coefficients(Number of Observations)
Year 0 Year 1 Year 2 Year 3 Year 4Year
01.00
(173)0.61
(121)0.68
(125)0.66
(133)0.55
(173)Year
10.62
(121)1.00
(121)0.70(92)
0.74(103)
0.50(121)
Year 2
0.68(125)
0.70(92)
1.00(126)
0.80(103)
0.69(126)
Year 3
0.66(133)
0.74(103)
0.80(103)
1.00(134)
0.75(134)
Year 4
0.55(173)
0.50(121)
0.69(126)
0.75(134)
1.00(175)
Correlation Matrix for EGFR
• Other issues:– Sample size is not constant (“unbalanced design”)
– How should time be modeled? – Are missing data and/or censoring a problem?
Example: Annual Assessment of Renal Function in Hypertensive Patients
Year N
0 173
1 121
2 126
3 134
4 175
Model interests are mean response profiles and relationships with covariates:
kiki XX 110i E( )Y
• Repeated Measures ANCOVA• Typically used for responses collected at
similar time points• Repeated measures models do not distinguish
between sources of variation– treat within-subject covariance as “nuisance”– use structured covariance matrices and weighted
least-squares
General Linear Mixed Model• Recall the “GLM”: • Extension of General Linear Model: There is only one
source of random variation in the above equation, assuming fixed effects
• Whenever a factor is considered to be random, it is a sample from a distribution of levels, and now the factor or variable brings a new source of random variation to the model
• The general linear mixed model is the most flexible approach for incorporating random effects
0 1 1 ... k kY X X
i i i i Y X Z b ε
TIME OUT: matrix notation• Matrix: a 2-dimensional array of numbers• Typical design matrix for the i-th subject with p covariates and k assessments:
• If β is a p×1 vector, then Xi•β is
111 21
112 22
1 2
1
1
1
p
p
i
pkk k
xx x
xx x
xx x
X
0 1 10
...p
k k p pk
X X X
General Linear Mixed Model
• Xi is the usual design matrix of fixed effects for the i-th
• β is a vector (i.e., a k×1 matrix) of regression coefficients
• Zi is a design matrix of random effects for the i-th subject
• b is (another) vector of regression coefficients(more on Z and b later)
• εi is a variance-covariance matrix
i i i i Y X Z b ε
• Part I: repeated (equally spaced) measures – like our renal function example
• Ignore the “random effects” part of the GLMM• Concentrate on εi
– No longer assume equal variances and independent observations
– If we assume a known, underlying distribution for Yi (guess which one) then we can model the underlying variance
– Use maximum-likelihood to estimate variances– Use weighted least-squares to estimate regression
parameters
General Linear Mixed Model
Time out: Maximum-likelihood
For the normal distribution which has PDF
the corresponding PDF for a sample of n independent identically distributed normal random variables (the likelihood “L”) is
We want to find values of μ and σ2 that “maximize” the probability of observed our given sample (the x’s).
Time out: Maximum-likelihood• Use calculus to do this:
– Because it’s easier to differentiate, take the natural log transform of L, “log(L)”
– Set log(L) = 0– Find derivatives with respect to each parameter
(first μ then σ)– These represent points of inflection– Since log(L) is monotonically increasing, the
inflexion points are maxima
Structured Covariance MatricesOutcome (i.e., response vector) must be
multivariate normal
( )
0
1
i 2
3
4
μμ
E μμμ
Y
20 0,1 0,2 0,3 0,4
20,1 1 1,2 1,3 1,4
2i 0,2 1,2 2 2,3 2,4
20,3 1,3 2,3 3 3,4
20,4 1,4 2,4 3,4 4
σ σ σ σ σσ σ σ σ σ
Var( ) = σ σ σ σ σσ σ σ σ σσ σ σ σ σ
Y
variance of Y at each measurement time
covariance between Y’s at two distinct timesrecall: Cov(Y0,Y1) = ρ0,1σ0σ1
Covariance StructuresSome common covariance structures are
– Independence: assumes uncorrelated observations, usual model if no repeated measures
– Compound symmetry or exchangeable: most “parsimonious”, assumes a single correlation for all repeated measures
– Autoregressive: assumes diminishing correlation based on distance of observations, popular in econometric analyses
– Unstructured or arbitrary: estimates every possible unique parameter
Covariance Structures• Independence: all of the observations are
independent – uncorrelated
5
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
I
2
2
22
2
2
Covariance Structures• Compound Symmetry: observations are correlated due to a
random subject effect
• Note: – Variances are constant across measurement times – Off-diagonal parameter estimates the “personal touch” of individual
subjects
2 2 2 2 2
2 2 2 2 2
2 2 2 2 2
2 2 2 2 2
2 2 2 2 2
2
2
2
2
2
s s s s s
s s s s s
s s s s s
s s s s s
s s s s s
Covariance Structures• Autoregressive (order 1): assumes serial
correlation – observations closely related in time are more similar
2 3 4
2 3
2 2
3 2
4 3 2
2 2 2 2 2
2 2 2 2 2
2 2 2 2 2
2 2 2 2 2
2 2 2 2 2
Covariance Structures• Unstructured: Observations are correlated with
no assumption of structure
In our example, requires estimation of 15 parameters
21 12 13 14 15
221 2 23 24 25
231 32 3 34 35
241 42 43 4 45
251 52 53 54 5
Covariance Estimates, Renal Function Example:EGFR at Baseline and 4 Years Follow-upIndependence
UnstructuredAutoregressive
Compound Symmetry758 0 0 0 0
0 758 0 0 00 0 758 0 00 0 0 758 00 0 0 0 758
2 parameters (correlation = 63%)
780 491 491 491 491491 780 491 491 491491 491 780 491 491491 491 491 780 491491 491 491 491 780
1 parameter (no correlation)
741 509 350 240 165509 741 509 350 240350 509 741 509 350240 350 509 741 509165 240 350 509 741
2 parameters (adjacent correlation = 69%)
955 826 672 495 378826 1556 899 722 466672 899 943 579 464495 722 579 542 380378 466 464 380 415
15 parameters (correlations 58% - 81%)
Are the observations correlated in our renal function example?
Pearson Correlation Coefficients(Number of Observations)
Year 0 Year 1 Year 2 Year 3 Year 4Year
01.00
(173)0.61
(121)0.68
(125)0.66
(133)0.55
(173)Year
10.62
(121)1.00
(121)0.70(92)
0.74(103)
0.50(121)
Year 2
0.68(125)
0.70(92)
1.00(126)
0.80(103)
0.69(126)
Year 3
0.66(133)
0.74(103)
0.80(103)
1.00(134)
0.75(134)
Year 4
0.55(173)
0.50(121)
0.69(126)
0.75(134)
1.00(175)
Correlation Matrix for EGFR
Comparing Covariance Estimates
Can compare nested models using likelihood-ratio testsStructure -2 Log Like DF Diff vs. Null P-value
Independence 6880.3 0 --- ---
Compound Symmetry 6541.2 1 339.1 <.0001
Autoregressive (1st order) 6557.7 1 322.6 <.0001
Unstructured 6357.8 14 522.5 <.0001
Unstructured provides significantly better fit than all three other structures (but there are more).
Recall: covariance parameters are “nuisance”, real interest lies in regression estimates.
How do covariance structures affect regression estimates?
IndependenceYear Mean SE
0 70.0 2.091 63.5 2.502 57.2 2.453 47.8 2.384 42.6 2.08
Compound SymmetryYear Mean SE
0 70.6 2.121 65.3 2.322 56.8 2.303 48.7 2.264 42.6 2.11
AutoregressiveYear Mean SE
0 70.2 2.071 65.0 2.242 56.7 2.233 48.7 2.184 42.6 2.06
UnstructuredYear Mean SE
0 70.8 2.341 67.0 3.222 56.8 2.453 48.7 1.824 42.6 1.54
Means are similar, SE’s affected a lot.
Add a covariate: baseline Max PSV
Estimated Variance-covariance MatrixYear 0 1 2 3 4
0 954.84 825.81 671.84 495.12 378.081 825.81 1555.93 898.97 722.95 465.822 671.84 898.97 943.21 579.08 463.393 495.12 722.95 579.08 541.74 379.554 378.08 465.82 463.39 379.55 414.87
Regression Parameter EstimatesEffect Estimate SEIntercept 42.6274 1.5397Year 0 28.1649 1.8817Year 1 24.4111 2.7176Year 2 14.1257 1.7508Year 3 6.0603 1.1598Year 4 0 .
Estimated Variance-covariance MatrixYear 0 1 2 3 4
0 968.70 840.19 688.07 505.85 385.811 840.19 1590.60 921.35 740.16 476.862 688.07 921.35 968.10 596.00 477.103 505.85 740.16 596.00 556.80 389.854 385.81 476.86 477.10 389.85 424.81
Model WITHOUT Covariate
Regression Parameter EstimatesEffect Estimate SEIntercept 43.0948 3.0424Year 0 28.1413 1.9166Year 1 24.4273 2.7822Year 2 14.0525 1.7813Year 3 6.0943 1.1895Year 4 0 .Max PSV -0.2623 1.8673
Model WITH Covariate
Can fit time as continuous rather than categories.
Regression Parameter EstimatesEffect Estimate SEIntercept 43.0948 3.0424Year 0 28.1413 1.9166Year 1 24.4273 2.7822Year 2 14.0525 1.7813Year 3 6.0943 1.1895Year 4 0 .Max PSV -0.2623 1.8673
Model With Year in Categories
Estimated Mean EGFRYear Mean SE
0 70.9 2.391 67.2 3.292 56.9 2.503 48.8 1.874 42.7 1.58
Model With Linear YearRegression Parameter Estimates
Effect Estimate SEIntercept 70.3751 3.3192Year (linear) -7.0691 0.4634Max PSV -0.8999 1.7653
Estimated Mean EGFRYear Mean SE
0 69.1 2.231 62.0 1.902 55.0 1.633 47.9 1.454 40.8 1.42
Which model is the better model?
Comparing Non-nested Models• Likelihood-ratio test only appropriate for nested
models. In general How do we determine which model is best?
• Use Akaike’s Information Criteria (AIC)
• Generally, lowest AIC is best• AICs within 2 are comparable – pick most
parsimonious (fewest p)
AIC = -2Log(L) + 2p(p = number of parameters)
Comparing Non-nested ModelsModel With Year in Categories Model With Linear Year
Model with linear year provides better fit (after correction for number of parameters).
Fit Statistics-2 Log Likelihood 6236.3AIC (smaller is better) 6278.3AICC (smaller is better) 6279.6BIC (smaller is better) 6344.5
Fit Statistics-2 Log Likelihood 6234.4AIC (smaller is better) 6270.4AICC (smaller is better) 6271.4BIC (smaller is better) 6327.1
Note: Even though AIC can be used to compare models that are not nested, it does require full maximum-likelihood (ML) rather than restricted maximum-likelihood (REML) if only difference between models are in fixed effects.
• Part II: repeated measures with unequal spacing or other types of clustering
• Example: the “Natural History” Database (NHD)– All available data within a specified time frame
were collected– Observations measured irregularly– Varying numbers of scans/patient– Same type sampling for renal function measures
• Use the “random effects” part of the GLMM
General Linear Mixed Model
Fixed vs. Random Effects
• In longitudinal data we often have both fixed and random effects
• Fixed– Finite set of levels– Contains all levels of interest for the study
• Random– Infinite (or large) set of levels– Levels in study are a sample from the
population of levels
i i i i Y X Z b ε
Fixed and Random Effects
7 Levels represent only a randomsample of a larger set of potential levels.
18
Clinic 23 Interest is in drawing inferences that are
41 valid for the complete population of levels.
ADrug B Fixed Effect
C
There are situations where estimation of an effect of interest can be both fixed and random.
Start simple: the Random Intercept Model• Simplest “mixed” model; incorporates a single
random effect for subject:
Where bi is the random subject effect and εi is measurement or sampling error
• By assumption, E(bi)= E(εi)=0, Var(bi)= , Var(εi)= , and Cov(bi, εi)=0 yielding
(Does this look familiar?)
iii εbβXY i
22iii σσVar(Var( b)) εbY
2σb2σ
Random Intercept Model• The introduction of a random effect also induces
correlation between observations on the same subject:
• Since the covariance between any pair is
Dude, that’s just compound-symmetry!
2
ikiiji
ikiikijiijikij
σ
Cov(
XCov(XYCov(Y
b
bb
bb
),
),),
ββ
2bσ
22
2
ikijσσ
σ)Y,Corr(Y
b
b
More General Models
• In balanced designs, random intercept model is the same as compound symmetry
• GLMM allows more general situations where subjects are measured over time– Spacing of measurements may or may not be
equal across subjects– The number of times an individual subject is
measured may vary– Change in the response over time is the focus of
analysis
Group Animal
Weight (in grams)
Week 1 Week 3 Week 4 Week 5 Week 6 Week 7
None 1 455 460 510 504 436 466
2 467 565 610 596 542 587
3 445 530 580 597 582 619
4 485 542 594 583 611 612
5 480 500 550 528 562 576
Low 6 514 560 565 524 552 597
7 440 480 536 484 567 569
8 495 570 569 585 576 677
9 520 590 610 637 671 702
10 503 555 591 605 649 675
High 11 496 560 622 622 632 670
12 498 540 589 557 568 609
13 478 510 568 555 576 605
14 545 565 580 601 633 649
15 472 498 540 524 532 583
Classic example: guinea pig growth data (Crowder and Hand, Analysis of Repeated Measures)
Animals on High Dose Vitamin EPlot of Weight (gm) vs. Weeks
450
500
550
600
650
700
1 2 3 4 5 6 7
Linear Growth Curves• Allow a subset of regression effects to vary
randomly (intercepts and slopes)• Fit individual regression lines for each subject• Fit an overall “mean” line that averages
(correctly) across the individual lines• For the i-th subject on the j-th measure:
[Note: time (tij) is both fixed and random.]
ijbb ij2i1iijij ttY 21
“mean” line (fixed effects) individual lines (random effects)
Two Animals on High Dose Vitamin EWeight (gm) vs. Weeks With Mean Line
ij2i1iij21
iiiii
tt
)|E(
bb
bb
ZXY
450
500
550
600
650
700
1 2 3 4 5 6 7
Conditional (subject-specific) mean of Yi given bi:
Marginal mean of Yi (averaged over dist’n of bi):
ij21
ii
t
)E(
XY
j1j21111j1j ttY 121 bb
Random Effects Covariance Structure• In the general linear mixed effects model, the
conditional covariance of Yi, given the random effects bi is
• The marginal covariance of Yi, averaged over the distribution of bi is
iiii RεbY )Cov()Cov( |
i'ii
i'iii
iii
RGZZ
εZbZ
εbZY
)Cov( )Cov(
)Cov( Cov()Cov( i )
Random Effects Covariance Structure• Typically we assume
• However, Cov(Yi) includes off-diagonal terms because of G (the variance matrix of the random effects)
• Usually assume G is unstructured• E.g., random intercepts and slope model:
structure) ce"independen" the pal, old (our σin
2IR i
in2
22
1211 σ)Cov( IZZY
'
iii gg
gg
21
Random Effects Covariance Structure• Expanding the previous expression:
• Note:– Number of covariance parameters is 4– Variance of Y influenced by both number and
spacing of time points (tij)– We have estimated the actual variance
components – We can introduce higher-order random effects
22ikij12ikij11ikij
222
2ijij11i
ttt tY Cov(Y
σtt Var(
ggg
ggg
)(),
) 122Y
Chick Growth Data (from Crowder and Hand) : Chicks on 4 diets had weight (gm) measured every 2 days over a 3 week period (12 measures total)
0
40
80
120
160
200
240
280
320
360
400
0 2 4 6 8 10 12 14 16 18 20 22
Appears that quadratic growth is appropriate
0
40
80
120
160
200
240
280
320
360
400
0 2 4 6 8 10 12 14 16 18 20 22
Fit quadratic growth (for fixed and random effects): ijebbb 2
ij3iij2i1i2ij3ij21ij ttttY
0
40
80
120
160
200
240
280
320
360
400
0 2 4 6 8 10 12 14 16 18 20 22
Variance estimates (days 0, 2, 4, …, 20, 21):
• Linear Growth: 266, 157, 148, 238, 428, 717, 1105, 1594, 2181, 2868, 3655, 4086
• Quadratic Growth: 72, 38, 71, 148, 266, 446, 727, 1172, 1863, 2905, 4421, 5402
Raw Data Fitted Lines
NHD: Renal Function(a relevant example)
UNITNO SCr EGFR YEAR YEAR2 RVD Prog000-79-25 1.0 77.3 0.0 0.0 0
1.1 69.0 1.1 1.2 01.0 76.8 2.6 6.6 01.4 51.9 3.6 13.2 01.9 36.4 4.9 24.0 01.6 44.2 5.8 34.1 0
001-00-05 1.4 38.1 0.0 0.0 01.6 32.6 0.7 0.4 02.1 23.8 2.1 4.2 01.8 28.3 3.0 9.1 01.3 41.1 4.0 16.2 01.4 37.7 4.9 24.1 0
eGF
R (
mL
/min
/1.7
3 m
^2)
0.0
20.0
40.0
60.0
80.0
100.0
120.0
140.0
160.0
180.0
200.0
Measurement Time (years)
0 1 2 3 4 5 6 7
eGFR vs. Time Relative to First Measure
eGF
R (
mL
/min
/1.7
3 m
^2)
0.0
20.0
40.0
60.0
80.0
100.0
120.0
140.0
160.0
180.0
200.0
Measurement Time (years)
0 1 2 3 4 5 6 7
eGFR vs. Time Relative to First Measure(fitted regression line)
GLMM for Change in EGFRCovariance Parameter Estimates
ParameterCov Parm Subject EstimateUN(1,1) unitno 916.78 Intercept b0
UN(2,1) unitno -129.76 Cov(b0, b1)UN(2,2) unitno 60.0098 Var(b1)UN(3,1) unitno 3.1800 Cov(b0, b2)UN(3,2) unitno -6.5409 Cov(b1, b2)UN(3,3) unitno 0.9845 Var(b2)Residual 146.01 σ2
Random effects: bib0 + b1t + b2t2
Solution for Fixed Effects
Effect EstimateStandard
Error DF t Value Pr > |t|Intercept 66.8787 1.6095 402 41.55 <.0001years -9.7747 0.7121 365 -13.73 <.0001yearssq 0.7864 0.1284 303 6.13 <.0001
Slopes fortt2
Positive slope for t2 diminishes loss of function with time.
GLMM for Change in EGFR
Time Estimate SEB/L 66.8787 1.6095
Year 1 57.8905 1.3958Year 2 50.4751 1.3086Year 3 44.6325 1.2174Year 4 40.3627 1.1189Year 5 37.6657 1.1883Year 6 36.5416 1.6577
Predicted Mean EGFR
Test for Effects of RVD Progression
Solution for Fixed Effects
Effect EstimateStandard
Error DF t Value Pr > |t|Intercept 69.1361 1.7726 386 39.00 <.0001
years -10.2662 0.7900 349 -13.00 <.0001
RASPROG -10.1470 4.5777 465 -2.22 0.0271
years*RASPROG 2.6346 2.1159 465 1.25 0.2137
yearssq 0.8425 0.1429 290 5.89 <.0001
RASPROG*yearssq -0.2653 0.3748 465 -0.71 0.4794
Advantages of the GLMM• A wide variety of covariance structures can be fit
(and compared)• It is possible to allow for different covariance
matrices by group (do not have to pool variance and assume homoscedasticity)
• Balanced data is not necessary• Covariates, even time-varying covariates may be
incorporated into the model• Many different types of questions may be addressed
Summary: Advantages of Longitudinal Study Design
• Permits the discovery of individual characteristics that can explain inter-individual differences in changes in health outcomes over time
• Fundamental objective - to measure within-individual changes
• Also of interest – to determine whether the within-individual changes in the response are related to selected covariates