From t-test to multilevel analyses Del-3 Stein Atle Lie, statistician, professor Uni Health, Uni Research http://folk.uib.no/msesl/GLM
Outline Pared t-test (Mean and standard deviation) Two-group t-test (Mean and standard deviations) Linear regression GLM (general linear models) GLMM (general linear mixed model) … PASW (former SPSS), Stata, R, gllamm (Stata)
Pared t-test The straightforward way to analyze two repeated measures is a pared t-test. Measure at time1 or location1 (e.g. Data1) is directly compared to measure at time2 or location2 (e.g. Data2) Is the difference between Data1 and Data2 (Diff = Data1-Data2) unlike 0?
Pared t-test The pared t-test will only be performed for complete (balanced) data. What happens if we delete two observations from data2? (Only 8 complete pairs remain)
Correlation Correlation (Bivariat-correlation) is only calculated for complete (balanced) data. pairs of data
Linear regression Ordinary linear regression Assumes data is Normal and i.i.d. (identical independent distributed)
Linear regression Assumptions - Residualer (ei): yi = a + b·xi + ei 1) e1, e2,…, en are independent normal distributed 2) The expectation of ei is: E(ei) = 0 3) The variance of ei is: var(Yi) = var(ei) = s2
Ordinary linear regression The formula for an ordinary regression can thus be expressed as: yi = b0 + b1·xi + ei ei ~N(0, se2)
Random intercept model Y Regression lines: yij = b0 + b1·xij+vij (x11,y11) b1 (xnp,ynp) b0+uj (xij,yij) su se X
Variance component model For a random variance component model, we can express the regression line(s) - and the variance components as yij = b0 + b1·xij + vij vij = uj + eij eij ~N(0, se2) (individual) uj ~N(0, su2) (group)
Random intercept model Alternatively we may express the formulas, for the simple variance component model, in terms of random intercepts: yij = b0j + b1·xij + eij b0j = b0 + uj eij ~N(0, se2) (individual) uj ~N(0, su2) (group)
Intra class correlation (ICC) The total variance is hence: se2 + su2 = sT2 The proportion of variance attributed to the group (level 2) - which is also the correlation between the observations within the group is: ICC = su2/sT2
Software Personal opinion PASW/SPSS Very easy to do simple models (menu/syntax) Arrange/restructure data Stata Steeper learning curve to start Easy () to extend the simpler models to more sophisticated models glamm R Steep learning curve Nice graphics
Cortisol data Cortisol level in saliva measured each morning in 3 days, in two periods* 55 individuals 278 observations (52 missing) * The real data was measured 5 times per day, in 3 days and 3 periods - from the article: Harris A, Marquis P, Eriksen HR, Grant I, Corbett R, Lie SA, Ursin H. Diurnal rhythm in British Antarctic personnel. Rural Remote Health. 2010 Apr-Jun;10(2):1351.
Cortisol data – missing data
Cortisol data – long data format
Cortisol data Period1 Period2
Linear model Stata: . glm kortisol period2 day2 day3, cluster(id) (. regress kortisol period2 day2 day3, cluster(id)) Generalized linear models No. of obs = 278 Optimization : ML Residual df = 274 (Std. Err. adjusted for 55 clusters in id) ------------------------------------------------------------------------------ | Robust kortisol | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- period2 | -2.536544 .9788702 -2.59 0.010 -4.455094 -.6179938 day2 | .1313347 .7238506 0.18 0.856 -1.287386 1.550056 day3 | .6528685 .7052775 0.93 0.355 -.72945 2.035187 _cons | 11.31802 .9542124 11.86 0.000 9.447799 13.18824
Linear mixed model (variance component) Stata: . gllamm kortisol period2 day2 day3, i(id) number of level 1 units = 278 number of level 2 units = 55 ------------------------------------------------------------------------------ kortisol | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- period2 | -2.600979 .6875339 -3.78 0.000 -3.94852 -1.253437 day2 | .05486 .8154391 0.07 0.946 -1.543371 1.653091 day3 | .5183787 .8242555 0.63 0.529 -1.097132 2.13389 _cons | 11.29695 .7666444 14.74 0.000 9.794358 12.79955 Variance at level 1 31.202774 (2.9334224) Variances and covariances of random effects level 2 (id) var(1): 8.6764463 (2.8796675) ICC=0.218
Linear mixed model (variance component) lmer(Kortisol~1+Day2+Day3+Period2 +(1|ID),data=kortisol) Random effects: Groups Name Variance Std.Dev. ID (Intercept) 8.8683 2.9780 Residual 31.6173 5.6229 Number of obs: 278, groups: ID, 55 Fixed effects: Estimate Std. Error t value (Intercept) 11.29105 0.77282 14.610 Day2 0.05431 0.82076 0.066 Day3 0.51766 0.82946 0.624 Period2 -2.60115 0.69204 -3.759 ICC=0.219
Cortisol data Period1 Period2
Linear mixed model (variance component) PASW: MIXED Kortisol BY ID WITH Period2 Day2 Day3 /FIXED=Period2 Day2 Day3 | SSTYPE(3) /METHOD=REML /PRINT=SOLUTION /RANDOM=ID | COVTYPE(VC). ICC=0.219
Linear mixed model (random intercept model) lmer(Kortisol~1+Day+Period2 +(1|ID),data=kortisol) Random effects: Groups Name Variance Std.Dev. ID (Intercept) 8.8879 2.9813 Residual 31.4891 5.6115 Number of obs: 278, groups: ID, 55 Fixed effects: Estimate Std. Error t value (Intercept) 11.2281 0.7394 15.186 Day 0.2546 0.4137 0.616 Period2 -2.6007 0.6907 -3.765 ICC=0.220
Linear mixed model (random intercept model) Period1 Period2
Linear mixed model (random slope model) lmer(Kortisol~1+Day+Period2 +(Day-1|ID),data=kortisol) Random effects: Groups Name Variance Std.Dev. ID Day 6.2228e-08 0.00024945 ! Residual 4.0499e+01 6.36390166 Number of obs: 278, groups: ID, 55 Fixed effects: Estimate Std. Error t value (Intercept) 11.2575 0.6948 16.202 Day 0.3227 0.4660 0.692 Period2 -2.5361 0.7644 -3.318
Linear mixed model (random slope model) Period1 Period2
Linear mixed model (random slope & intercept) lmer(Kortisol~1+Day+Period2 +(1+Day|ID),data=kortisol) Random effects: Groups Name Variance Std.Dev. Corr ID (Intercept) 10.88014 3.29851 Day 0.10535 0.32457 -1.000 Residual 31.38000 5.60179 Number of obs: 278, groups: ID, 55 Fixed effects: Estimate Std. Error t value (Intercept) 11.2138 0.7629 14.698 Day 0.2656 0.4149 0.640 Period2 -2.5940 0.6891 -3.764 ICC=0.257
Linear mixed model (random slope model) Period1 Period2
Summary The interpretation of parameter estimates of categorical variables (preferably dummy variables) from linear models can be interpreted as mean differences, as from ordinary t-test This is equivalent in models for repeated or clustered observations!