SAS Code for Data Manipulation: SPSS Code for Data Manipulation: STATA Code for Data Manipulation: Psyc 945 Example 1 page 1

Size: px
Start display at page:

Download "SAS Code for Data Manipulation: SPSS Code for Data Manipulation: STATA Code for Data Manipulation: Psyc 945 Example 1 page 1"

Transcription

1 Psyc 945 Example page Example : Unconditional Models for Change in Number Match 3 Response Time (complete data, syntax, and output available for SAS, SPSS, and STATA electronically) These data come from a short-term longitudinal study of 6 observations over weeks for 0 adults age years. The goal is to see how performance on this processing speed task ( number match 3 ), as measured by response time in milliseconds, declines (improves) over the 6 practice sessions. We will examine both polynomial and piecewise models to describe individual differences in within-person change across sessions. SAS Code for Data Manipulation: * SAS code to import data; DATA work.example34; SET example.example34; * Center time for polynomial models; csess = Session - ; LABEL csess = "csess: Session Centered at "; * Create piecewise slopes; IF Session = THEN DO; Slope = 0; Slope6 = 0; END; ELSE IF Session = THEN DO; Slope = ; Slope6 = 0; END; ELSE IF Session = 3 THEN DO; Slope = ; Slope6 = ; END; ELSE IF Session = 4 THEN DO; Slope = ; Slope6 = ; END; ELSE IF Session = 5 THEN DO; Slope = ; Slope6 = 3; END; ELSE IF Session = 6 THEN DO; Slope = ; Slope6 = 4; END; LABEL Slope = "Slope: Early Practice Slope (Session -)" Slope6 = "Slope6: Later Practice Slope (Session -6)"; RUN; SPSS Code for Data Manipulation: * SPSS code to import data. GET FILE = "example/example34.sav". DATASET NAME example34 WINDOW=FRONT. * Center time for polynomial models. COMPUTE csess = session -. VARIABLE LABELS csess "csess: Session Centered at ". * Create piecewise slopes. RECODE session (=0) ( THRU HI=) INTO Slope. RECODE session (LO THRU =0) (3=) (4=) (5=3) (6=4) INTO Slope6. VARIABLE LABELS Slope "Slope: Early Practice Slope (Session -)" Slope6 "Slope6: Later Practice Slope (Session -6)". STATA Code for Data Manipulation: * Center time for polynomial models (and make quadratic version) gen csess = session label variable csess "csess: Session Centered at " gen csess = csess * csess label variable csess "csess: Quadratic Session Centered at " * Create piecewise slopes gen slope = session gen slope6 = session recode slope (=0) if session== recode slope (=) if session== recode slope (3=) if session==3 recode slope (4=) if session==4 recode slope (5=) if session==5 recode slope (6=) if session==6 recode slope6 (=0) if session== recode slope6 (=0) if session== recode slope6 (3=) if session==3 recode slope6 (4=) if session==4 recode slope6 (5=3) if session==5 recode slope6 (6=4) if session==6 label variable slope "slope: Early Practice Slope (Session -)" label variable slope6 "slope6: Later Practice Slope (Session -6)"

2 Psyc 945 Example page Model a. Most Conservative Baseline Empty Means, Random Intercept Level : yti 0i eti Level : Intercept: U 0i 00 0i TITLE "SAS Model a: Empty Means, Random Intercept Only"; PROC MIXED DATA=work.example34 NOCLPRINT NOITPRINT COVTEST NAMELEN=00 IC METHOD=REML; MODEL nm3rt = / SOLUTION DDFM=Satterthwaite; RANDOM INTERCEPT / G V VCORR TYPE=UN SUBJECT=ID; REPEATED session / R TYPE=VC SUBJECT=ID; RUN; TITLE; TITLE "SPSS Model a: Empty Means, Random Intercept". MIXED nm3rt BY ID session /PRINT = SOLUTION TESTCOV G R /FIXED = /RANDOM = INTERCEPT SUBJECT(ID) COVTYPE(UN) /REPEATED = session SUBJECT(ID) COVTYPE(ID). * STATA Model a: Empty Means, Random Intercept xtmixed nm3rt, id:, /// variance reml covariance(unstructured) residuals(independent,t(session)), estat ic, n(0) estat recovariance, level(id) METHOD = ML or REML (default) CLASS = categorical predictors, nesting MODEL dv = fixed effects / print solution RANDOM = person variances in G REPEATED = residuals in R matrix MIXED dv BY categorical predictors WITH continuous predictors or ML /PRINT = regression solution /FIXED = predictors for means model /RANDOM = person variances in G DV = nm3rt, random part after Level ID is PersonID, random intercept by default Print variances instead of SD, use reml covariance(unstructured) refers to G matrix residuals(independent) refers to R matrix by session estat ic Print IC given N = 0 persons Estimated R Matrix for ID Estimated G Matrix Participant Row Effect ID Col Intercept This is the level- G matrix, just a random intercept variance so far. Estimated V Matrix for ID Estimated V Correlation Matrix for ID This level- R matrix (with equal variance over time, no covariance of any kind, known as VC or independence) will be used repeatedly as we add fixed The V matrix is the total variance-covariance matrix after combining the level- G and level- R matrices.

3 Psyc 945 Example page 3 Covariance Parameter Estimates Z Cov Parm Subject Estimate Error Value Pr Z UN(,) ID <.000 Session ID <.000 Null Model Likelihood Ratio Test DF Chi-Square Pr > ChiSq <.000 NegLogLike Parms AIC AICC HQIC BIC CAIC Effect Estimate Error DF t Value Pr > t Intercept <.000 Model b. Most Liberal Baseline Saturated Means, Unstructured Variances (Model Answer Key) TITLE "SAS Model b: Saturated Means, Unstructured Variances"; PROC MIXED DATA=work.example34 NOCLPRINT NOITPRINT COVTEST NAMELEN=00 IC METHOD=REML; MODEL nm3rt = session / SOLUTION DDFM=Satterthwaite; REPEATED session / R RCORR TYPE=UN SUBJECT=ID; LSMEANS session /; RUN; TITLE; TITLE "SPSS Model b: Saturated Means, Unstructured Variances". MIXED nm3rt BY ID session /PRINT = SOLUTION TESTCOV R /FIXED = session /REPEATED = session SUBJECT(ID) COVTYPE(UN) /EMMEANS = TABLES(session). * STATA Model b: Saturated Means, Unstructured Variances xtmixed nm3rt ib(last).session, id:, noconstant /// variance reml residuals(unstructured, t(session)), estat ic, n(0), contrast session, // omnibus test of mean differences margins i.session, // observed means per session marginsplot name(observed_means, replace) // plot observed means Calculate the ICC for the Number Match 3 outcome: ICC This null model LRT tells us that the random intercept variance is significantly greater than 0, and thus so is the ICC. REML only counts the # parameters in the model for the variance (not fixed effects). This is the fixed intercept (just the grand mean so far). Placing session on the CLASS/BY statements and in the FIXED/MODEL statements treats it as a categorical predictor. So this is an ANOVA means model. No RANDOM statements mean no random effects. i. indicates categorical predictor of session (ref=last to match others) noconstant = no random intercept (just R matrix) Estimated R Matrix for ID Estimated R Correlation Matrix for ID This Unstructured R matrix estimates all variances and covariances separately. THIS IS THE DATA we are trying to duplicate with our model for the variance

4 Psyc 945 Example page 4 NegLogLike Parms AIC AICC HQIC BIC CAIC Effect Session # Estimate Error DF t Value Pr > t Intercept <.000 Session <.000 Session <.000 Session Session Session Session Mean diffs relative to session 6 (which is the intercept given that it is the highest value) Type 3 Tests of Fixed Effects Num Den Effect DF DF F Value Pr > F Session <.000 This is the omnibus test of mean differences across 6 sessions. Least Squares Means Effect Session # Estimate Error DF t Value Pr > t Session <.000 Session <.000 Session <.000 Session <.000 Session <.000 Session <.000 These are the means per session that the fixed effects will be trying to reproduce. So here is what are we trying to model means and variances, where model b is the data: Predicted Means By Model Predicted Variance By Model Saturated Means Model b Random Intercept Model a Unstructured Model b Random Intercept Model a, ,000, ,000,800 50,000 Mean RT,700 RT Variance 00,000,600 50,000, Session 00, Session

5 Psyc 945 Example page 5 Model a. Fixed Linear Time, Random Intercept Level : y Session e Level : Intercept: 0i 00 U0i Linear Session: ti 0i i ti ti i 0 TITLE "SAS Model a: Fixed Linear Time, Random Intercept"; PROC MIXED DATA=work.example35 NOCLPRINT NOITPRINT COVTEST NAMELEN=00 IC METHOD=REML; MODEL nm3rt = csess / SOLUTION DDFM=Satterthwaite; RANDOM INTERCEPT / G V VCORR TYPE=UN SUBJECT=ID; REPEATED session / R TYPE=VC SUBJECT=ID; RUN; TITLE; TITLE "SPSS Model a: Fixed Linear Time, Random Intercept". MIXED nm3rt BY ID session WITH csess /PRINT = SOLUTION TESTCOV G R /FIXED = csess /RANDOM = INTERCEPT SUBJECT(ID) COVTYPE(UN) /REPEATED = session SUBJECT(ID) COVTYPE(ID). * STATA Model a: Fixed Linear Time, Random Intercept xtmixed nm3rt c.csess, id:, /// variance reml covariance(un) residuals(independent,t(session)), estat ic, n(0), estimates store FixLin Estimated V Matrix for ID Estimated V Correlation Matrix for ID Covariance Parameter Estimates Z Cov Parm Subject Estimate Error Value Pr Z UN(,) ID <.000 Session ID <.000 NegLogLike Parms AIC AICC HQIC BIC CAIC The predictor of csess will be treated as continuous given that it is not on the CLASS statement (SAS) and it is on WITH (SPSS). DV = nm3rt, c. means continuous fixed slope for csess Level ID is id, random intercept by default estimates save results as FixLin for next LRT Relative to the empty means, random intercept model a, the fixed linear effect of session explained ~% of the residual variance (which made the random intercept variance increase due to its smaller residual variance correction factor). Effect Estimate Error DF t Value Pr > t Intercept <.000 Csess <.000 The fixed linear effect of csess is significant according to the Wald test (p-value for fixed effect).

6 Psyc 945 Example page 6 Model b. Random Linear Time Level : y Session e Level : Intercept: 0i 00 U0i Linear Session: U ti 0i i ti ti i 0 i TITLE "SAS Model b: Random Linear Time"; PROC MIXED DATA=work.example35 NOCLPRINT NOITPRINT COVTEST NAMELEN=00 IC METHOD=REML; MODEL nm3rt = csess / SOLUTION DDFM=Satterthwaite; RANDOM INTERCEPT csess / G V VCORR TYPE=UN SUBJECT=ID; REPEATED session / R TYPE=VC SUBJECT=ID; RUN; TITLE; TITLE "SPSS Model b: Random Linear Time". Now there are random effects: intercept and linear MIXED nm3rt BY ID session WITH csess slope, given by csess on the RANDOM statements. /PRINT = SOLUTION TESTCOV G R /FIXED = csess /RANDOM = INTERCEPT csess SUBJECT(ID) COVTYPE(UN) /REPEATED = session SUBJECT(ID) COVTYPE(ID). * STATA Model b: Random Linear Time xtmixed nm3rt c.csess, id: csess, /// variance reml covariance(un) residuals(independent,t(session)), estat ic, n(0), estat recovariance, level(id), estimates store RandLin, lrtest RandLin FixLin DV = nm3rt, c. means continuous fixed slope for csess Level ID is id, random intercept and csess now estimates save results as RandLin for LRT Estimated R Matrix for ID Estimated G Matrix Participant Row Effect ID Col Col Intercept Csess Estimated G Correlation Matrix ID: Participant Row Effect ID Col Col Intercept csess GCORR shows the correlation among random effects. Estimated V Matrix for ID The V matrix is the total variance-covariance matrix after combining the level- G and level- R matrices. Now the variances and covariances are predicted to change based on time.

7 Psyc 945 Example page 7 How the V matrix variances and covariances get calculated in a random linear time model: Vi matrix: VarianceytimeU Session 0 U Session U 0 e V i matrix: Covariance y A,yB U A B U AB U 0 0 Estimated V Correlation Matrix for ID The VCORR matrix is the correlation version. The ICC is now predicted to change over time, too (and conditional on linear time). Covariance Parameter Estimates Z Cov Parm Subject Estimate Error Value Pr Z UN(,) ID <.000 UN(,) ID UN(,) ID <.000 Session ID <.000 NegLogLike Parms AIC AICC HQIC BIC CAIC Effect Estimate Error DF t Value Pr > t Intercept <.000 Csess <.000 Model 3a. Fixed Quadratic, Random Linear Time Level : y Session Session e Level : Intercept: 0i 00 U0i Linear Session: i 0 Ui Quadratic Session: ti 0i i ti i ti ti i 0 TITLE "SAS Model 3a: Fixed Quadratic, Random Linear Time"; PROC MIXED DATA=work.example35 NOCLPRINT NOITPRINT COVTEST NAMELEN=00 IC METHOD=REML; MODEL nm3rt = csess csess*csess / SOLUTION DDFM=Satterthwaite; RANDOM INTERCEPT csess / G V VCORR TYPE=UN SUBJECT=ID; REPEATED session / R TYPE=VC SUBJECT=ID; RUN; TITLE; TITLE "SPSS Model 3a: Fixed Quadratic, Random Linear Time". MIXED nm3rt BY ID session WITH csess /PRINT = SOLUTION TESTCOV G R /FIXED = csess csess*csess /RANDOM = INTERCEPT csess SUBJECT(ID) COVTYPE(UN) /REPEATED = session SUBJECT(ID) COVTYPE(ID). * STATA Model 3a: Fixed Quadratic, Random Linear Time xtmixed nm3rt c.csess c.csess#c.csess, id: csess, /// variance reml covariance(un) residuals(independent,t(session)), estat ic, n(0), Is the random linear time model (b) better than the fixed linear time, random intercept model (a)? Yep, ΔLL= 43, which is bigger than the critical value of 5.99ish on df =~ish Interactions can be defined on the fly in SAS and SPSS using *. Interactions can be defined on the fly in STATA using # for fixed effects, but not for random effects.

8 Psyc 945 Example page 8 estat recovariance, level(id), estimates store FixQuad Estimated R Matrix for ID Estimated G Matrix ID: Participant Row Effect ID Col Col Intercept csess GCORR shows intercept slope correlation r =.53 Estimated V Matrix for ID Estimated V Correlation Matrix for ID Covariance Parameter Estimates Z Cov Parm Subject Estimate Error Value Pr Z UN(,) ID <.000 UN(,) ID UN(,) ID <.000 session ID <.000 Relative to the random linear time model b, the fixed quadratic effect of session explained another ~6% of the residual variance (which made the random intercept variance increase due to its residual variance correction factor). NegLogLike Parms AIC AICC HQIC BIC CAIC Effect Estimate Error DF t Value Pr > t Intercept <.000 Csess <.000 Csess*Csess <.000 The fixed quadratic effect of csess is significant according to the Wald test (p-value for fixed effect).

9 Psyc 945 Example page 9 Model 3b. Random Quadratic Time (and an example of ESTIMATE/TEST/LINCOM statements) Level : y Session Session e Level : Intercept: 0i 00 U0i Linear Session: i 0 Ui Quadratic Session: U ti 0i i ti i ti ti i 0 i TITLE "SAS Model 3b: Random Quadratic Time"; PROC MIXED DATA=work.example35 NOCLPRINT NOITPRINT COVTEST NAMELEN=00 IC METHOD=REML; MODEL nm3rt = csess csess*csess / SOLUTION DDFM=Satterthwaite; RANDOM INTERCEPT csess csess*csess / G V VCORR TYPE=UN SUBJECT=ID; REPEATED session / R TYPE=VC SUBJECT=ID; ESTIMATE "Intercept at Session " intercept csess 0 csess*csess 0; ESTIMATE "Intercept at Session " intercept csess csess*csess ; ESTIMATE "Intercept at Session 3" intercept csess csess*csess 4; ESTIMATE "Intercept at Session 4" intercept csess 3 csess*csess 9; ESTIMATE "Intercept at Session 5" intercept csess 4 csess*csess 6; ESTIMATE "Intercept at Session 6" intercept csess 5 csess*csess 5; * Predicting linear rate of change at each session (linear changes by *quad); ESTIMATE "Linear Slope at Session " csess csess*csess 0; ESTIMATE "Linear Slope at Session " csess csess*csess ; ESTIMATE "Linear Slope at Session 3" csess csess*csess 4; ESTIMATE "Linear Slope at Session 4" csess csess*csess 6; ESTIMATE "Linear Slope at Session 5" csess csess*csess 8; ESTIMATE "Linear Slope at Session 6" csess csess*csess 0; RUN; TITLE; TITLE "SPSS Model 3b: Random Quadratic Time". MIXED nm3rt BY ID session WITH csess /PRINT = SOLUTION TESTCOV G R /FIXED = csess csess*csess /RANDOM = INTERCEPT csess csess*csess SUBJECT(ID) COVTYPE(UN) /REPEATED = session SUBJECT(ID) COVTYPE(ID) /TEST = "Intercept at Session " intercept csess 0 csess*csess 0 /TEST = "Intercept at Session " intercept csess csess*csess /TEST = "Intercept at Session 3" intercept csess csess*csess 4 /TEST = "Intercept at Session 4" intercept csess 3 csess*csess 9 /TEST = "Intercept at Session 5" intercept csess 4 csess*csess 6 /TEST = "Intercept at Session 6" intercept csess 5 csess*csess 5 /TEST = "Linear Slope at Session " csess csess*csess 0 /TEST = "Linear Slope at Session " csess csess*csess /TEST = "Linear Slope at Session 3" csess csess*csess 4 /TEST = "Linear Slope at Session 4" csess csess*csess 6 /TEST = "Linear Slope at Session 5" csess csess*csess 8 /TEST = "Linear Slope at Session 6" csess csess*csess 0. * STATA Model 3b: Random Quadratic Time The random statement will xtmixed nm3rt c.csess c.csess#c.csess, id: csess csess, /// not accept interaction terms, variance reml covariance(un) residuals(independent,t(session)), so we are using the csess estat ic, n(0), created manually before. estat recovariance, level(id), estimates store RandQuad, lrtest RandQuad FixQuad, margins, at(c.csess=(0()5)) vsquish // intercepts per session marginsplot, name(predicted_means, replace) // plot intercepts margins, at(c.csess=(0()5)) dydx(c.csess) vsquish // linear slope per session marginsplot, name(change_in_linear_slope, replace) // plot quadratic effect

10 Psyc 945 Example page 0 Estimated R Matrix for ID Estimated G Matrix Participant Row Effect ID Col Col Col3 Intercept Csess Csess*Csess Estimated G Correlation Matrix ID: Participant Row Effect ID Col Col Col3 Intercept csess csess*csess Estimated V Matrix for ID The V matrix is the total variance-covariance matrix after combining the level- G and level- R matrices. The variances and covariances are predicted to change based on time, but differently. How the V matrix variances and covariances get calculated in a random quadratic time model: Predicted Variance at Time T: Var(y T ) = σ + τ + *T*τ + T *τ + *T *τ + *T 3 *τ + T 4 *τ Predicted Covariance between Time A and B: Cov(y A, y B ) = τ + (A+B)*τ + (AB)*τ + (A +B )*τ + (AB )+(A B)*τ + (A B )*τ Estimated V Correlation Matrix for ID Covariance Parameter Estimates Z Cov Parm Subject Estimate Error Value Pr Z UN(,) ID <.000 UN(,) ID UN(,) ID <.000 UN(3,) ID UN(3,) ID <.000 UN(3,3) ID Session ID <.000

11 Psyc 945 Example page NegLogLike Parms AIC AICC HQIC BIC CAIC Effect Estimate Error DF t Value Pr > t Intercept <.000 Csess <.000 Csess*Csess <.000 Is the random quadratic model (3b) better than the fixed quadratic, random linear model (3a)? Yep, ΔLL= 39, which is bigger than the critical value of 7.8ish on df=~3ish Computing random effects confidence intervals for each random effect: Random Effect 95% CI = fixed effect ±.96* Random Variance 0 0 U 0 U Intercept 95% CI = γ ±.96* τ,945.9 ±.96* 76,09 = 96 to, U Linear Time Slope 95% CI = γ ±.96* τ 0.9 ±.96* 5,840 = 436 to 94 Quadratic Time Slope 95% CI = γ ±.96* τ 3.9 ±.96* 634 = 36 to 63 Estimates Label Estimate Error DF t Value Pr > t Intercept at Session <.000 Intercept at Session <.000 Intercept at Session <.000 Intercept at Session <.000 Intercept at Session <.000 Intercept at Session <.000 These are the quadraticmodel-predicted means (intercepts) per session. Linear Trend at Session <.000 Linear Trend at Session <.000 Linear Trend at Session <.000 Linear Trend at Session <.000 Linear Trend at Session Linear Trend at Session These are the instantaneous linear slopes at each session. Note how the SEs narrow towards the middle sessions. How well do the predicted means, variances, and covariances from the random quadratic model (3b) match the original means, variances, and covariances from the saturated means model (b)?,000 Predicted Means By Model Saturated Means Model b Random Intercept Model a Random Linear Model b Random Quadratic Model 3b 350,000 Predicted Variance By Model Unstructured Model b Random Intercept Model a Random Linear Model b Random Quadratic Model 3b, ,000 Meant RT,800,700 RT Variance 50,000 00,000,600 50,000, Session 00, Session

12 Psyc 945 Example page The quadratic model appears to be a good contender, but let s examine how well a two-slope piecewise model might fit these same data Model 4a: Fixed Slope, Fixed Slope6, Random Intercept Model Level : y Slope Slope6 e Level : Intercept: 0i 00 U0i Slope: i 0 Slope6: ti 0i i ti i ti ti i 0 TITLE "Model 4a: Fixed Slope, Fixed Slope6, Random Intercept Model"; PROC MIXED DATA=work.example34 NOCLPRINT NOITPRINT COVTEST NAMELEN=00 IC METHOD=REML; MODEL nm3rt = Slope Slope6 / SOLUTION DDFM=Satterthwaite; RANDOM INTERCEPT / V VCORR TYPE=UN SUBJECT=ID; REPEATED session / R TYPE=VC SUBJECT=ID; RUN; TITLE; TITLE "SPSS Model 4a: Fixed Slope, Fixed Slope6, Random Intercept Model". MIXED nm3rt BY ID session WITH Slope Slope6 /PRINT = SOLUTION TESTCOV G R /FIXED = Slope Slope6 /RANDOM = INTERCEPT SUBJECT(ID) COVTYPE(UN) /REPEATED = session SUBJECT(ID) COVTYPE(ID). * STATA Model 4a: Fixed Slope, Fixed Slope6, Random Intercept Model xtmixed nm3rt c.slope c.slope6, id:, /// variance reml covariance(un) residuals(independent,t(session)), estat ic, n(0), estimates store FixPiece Estimated R Matrix for ID This R matrix VC structure (equal variance over time, no covariance of any kind) will be used repeatedly as we add fixed and random piecewise slopes to the model. Estimated G Matrix Row Effect Person ID Col Intercept Estimated V Matrix for ID This random intercept model predicts a compound symmetry pattern for the V matrix (equal variance, equal covariance over time). Estimated V Correlation Matrix for ID

13 Psyc 945 Example page Covariance Parameter Estimates Z Cov Parm Subject Estimate Error Value Pr > Z UN(,) ID <.000 Session ID <.000 NegLogLike Parms AIC AICC HQIC BIC CAIC Effect Estimate Error DF t Value Pr > t Intercept <.000 Slope <.000 RATE OF CHANGE FROM SESSION - Slope <.000 RATE OF CHANGE FROM SESSION -6 Session Number-Match 3 Slope + Slope Deviation Slope Slope Observed Means Piecewise Linear Two Slopes Slope 0 Slope RT Two Direct Slopes 96 64(Slope) 33(Slope6) Session Model 4b: Random Slope, Fixed Slope6 Model Level : y Slope Slope6 e Level : Intercept: 0i 00 U0i Slope: i 0 Ui Slope6: ti 0i i ti i ti ti i 0 TITLE "Model 4b: Random Slope, Fixed Slope6 Model"; PROC MIXED DATA=work.example34 NOCLPRINT NOITPRINT COVTEST NAMELEN=00 IC METHOD=REML; MODEL nm3rt = Slope Slope6 / SOLUTION DDFM=Satterthwaite; RANDOM INTERCEPT Slope / G GCORR V VCORR TYPE=UN SUBJECT=ID; REPEATED session / R TYPE=VC SUBJECT=ID; RUN; TITLE; TITLE "SPSS Model 4b: Random Slope, Fixed Slope6 Model".

14 Psyc 945 Example page 4 MIXED nm3rt BY ID session WITH Slope Slope6 /PRINT = SOLUTION TESTCOV G R /FIXED = Slope Slope6 /RANDOM = INTERCEPT Slope SUBJECT(ID) COVTYPE(UN) /REPEATED = session SUBJECT(ID) COVTYPE(ID). * STATA Model 4b: Random Slope, Fixed Slope6 Model xtmixed nm3rt c.slope c.slope6, id: slope, /// variance reml covariance(un) residuals(independent,t(session)), estat ic, n(0), estat recovariance, level(id), estimates store RandP, lrtest RandP FixPiece Estimated R Matrix for ID Estimated G Matrix Row Effect Person ID Col Col Intercept Slope Estimated G Correlation Matrix Row Effect Person ID Col Col Intercept Slope Estimated V Matrix for ID The pattern of variance and covariances in V is now compound symmetry from session onward because slope6 is fixed. Estimated V Correlation Matrix for ID Covariance Parameter Estimates Z Cov Parm Subject Estimate Error Value Pr Z UN(,) ID <.000 UN(,) ID UN(,) ID <.000 Session ID <.000

15 Psyc 945 Example page 5 NegLogLike Parms AIC AICC HQIC BIC CAIC Is random slope significant? Yep, ΔLL= 63, which is bigger than the critical value of 5.99ish on df =~ish Effect Estimate Error DF t Value Pr > t Intercept <.000 Slope <.000 RATE OF CHANGE FROM SESSION - Slope <.000 RATE OF CHANGE FROM SESSION -6 Model 4c: Random Slope, Random Slope6 Model Level : y Slope Slope6 e Level : Intercept: 0i 00 U0i Slope: i 0 Ui Slope6: U ti 0i i ti i ti ti i 0 i TITLE "Model 4c: Random Slope, Random Slope6 Model"; PROC MIXED DATA=work.example34 NOCLPRINT NOITPRINT COVTEST NAMELEN=00 IC METHOD=REML; MODEL nm3rt = Slope Slope6 / SOLUTION DDFM=Satterthwaite; RANDOM INTERCEPT Slope Slope6 / G GCORR V VCORR TYPE=UN SUBJECT=ID; REPEATED session / R TYPE=VC SUBJECT=ID; ESTIMATE "Session Predicted Mean" Intercept Slope 0 Slope6 0; ESTIMATE "Session Predicted Mean" Intercept Slope Slope6 0; ESTIMATE "Session 3 Predicted Mean" Intercept Slope Slope6 ; ESTIMATE "Session 4 Predicted Mean" Intercept Slope Slope6 ; ESTIMATE "Session 5 Predicted Mean" Intercept Slope Slope6 3; ESTIMATE "Session 6 Predicted Mean" Intercept Slope Slope6 4; ESTIMATE "Difference between slopes" Slope - Slope6 ; RUN; TITLE; TITLE "SPSS Model 4c: Random Slope, Random Slope6 Model". MIXED nm3rt BY ID session WITH Slope Slope6 /PRINT = SOLUTION TESTCOV G R /FIXED = Slope Slope6 /RANDOM = INTERCEPT Slope Slope6 SUBJECT(ID) COVTYPE(UN) /REPEATED = session SUBJECT(ID) COVTYPE(ID) /TEST = "Session Predicted Mean" Intercept Slope 0 Slope6 0 /TEST = "Session Predicted Mean" Intercept Slope Slope6 0 /TEST = "Session 3 Predicted Mean" Intercept Slope Slope6 /TEST = "Session 4 Predicted Mean" Intercept Slope Slope6 /TEST = "Session 5 Predicted Mean" Intercept Slope Slope6 3 /TEST = "Session 6 Predicted Mean" Intercept Slope Slope6 4 /TEST = "Difference between slopes" Slope - Slope6. * STATA Model 4c: Random Slope, Random Slope6 Model xtmixed nm3rt c.slope c.slope6, id: slope slope6, /// variance reml covariance(un) residuals(independent,t(session)), estat ic, n(0), estat recovariance, level(id), estimates store RandP, lrtest RandP RandP lincom -*c.slope + *c.slope6 // difference between slopes

16 Psyc 945 Example page 6 Estimated R Matrix for ID Estimated G Matrix Row Effect Person ID Col Col Col3 Intercept Slope Slope Estimated G Correlation Matrix Row Effect Person ID Col Col Col3 Intercept Slope Slope Estimated V Matrix for ID Estimated V Correlation Matrix for ID Covariance Parameter Estimates Z Cov Parm Subject Estimate Error Value Pr Z UN(,) ID <.000 UN(,) ID UN(,) ID <.000 UN(3,) ID UN(3,) ID UN(3,3) ID <.000 Session ID <.000 NegLogLike Parms AIC AICC HQIC BIC CAIC Is random slope6 significant? Yep, ΔLL= 44, which is bigger than the critical value of 7.8ish on df =~3ish Effect Estimate Error DF t Value Pr > t Intercept <.000 Slope <.000 RATE OF CHANGE FROM SESSION - Slope <.000 RATE OF CHANGE FROM SESSION -6

17 Psyc 945 Example page 7 Estimates Label Estimate Error DF t Value Pr > t Session Predicted Mean <.000 Session Predicted Mean <.000 Session 3 Predicted Mean <.000 Session 4 Predicted Mean <.000 Session 5 Predicted Mean <.000 Session 6 Predicted Mean <.000 Difference between slopes Random Effect 95% CI = fixed effect ±.96* Random Variance 0 Intercept 95% CI = γ ±.96* τ,96.9 ±.96* 84,3 = 97 to 3, U Slope 95% CI = γ ±.96* τ 63.6 ±.96* 63,954 = 659 to 3 0 U Slope6 95% CI = γ ±.96* τ 3.9 ±.96*,67 = 33 to 67 0 U So far we ve examined one way to fit piecewise slopes models direct slopes that represent the change during each time period. Let s now examine an alternative specification: slope + deviation slope, which can be useful in examining individual differences in differential change between time periods. Model 5c: Random Slope, Random Deviation Slope Model Level : y Slope6 Slope6 e Level : Intercept: 0i 00 U0i Slope: i 0 Ui Slope6: U ti 0i i ti i ti ti i 0 i TITLE "Model 5c: Random Slope6, Random Slope6 Model"; PROC MIXED DATA=work.example34 NOCLPRINT NOITPRINT COVTEST NAMELEN=00 IC METHOD=REML; MODEL nm3rt = csess Slope6 / SOLUTION DDFM=Satterthwaite; RANDOM INTERCEPT csess Slope6 / G GCORR V VCORR TYPE=UN SUBJECT=ID; REPEATED session / R TYPE=VC SUBJECT=ID; ESTIMATE "Slope between sessions -6" csess Slope6 ; RUN; TITLE; TITLE "SPSS Model 5c: Random Slope6, Random Slope6 Model". MIXED nm3rt BY ID session WITH csess Slope6 /PRINT = SOLUTION TESTCOV G R /FIXED = csess Slope6 /RANDOM = INTERCEPT csess Slope6 SUBJECT(ID) COVTYPE(UN) /REPEATED = session SUBJECT(ID) COVTYPE(ID) /TEST = "Slope between sessions -6" csess Slope6. * STATA Model 5c: Random Slope6, Random Slope6 Model xtmixed nm3rt c.csess c.slope6, id: csess slope6, /// variance reml covariance(un) residuals(independent,t(session)), estat ic, n(0) estat recovariance, level(id) lincom *c.csess + *c.slope6 // slope between sessions to 6

18 Psyc 945 Example page 8 Estimated R Matrix for ID Estimated G Matrix Row Effect Person ID Col Col Col3 Intercept csess Slope Estimated G Correlation Matrix Row Effect Person ID Col Col Col3 Intercept csess Slope Estimated V Matrix for ID Estimated V Correlation Matrix for ID Covariance Parameter Estimates Z Cov Parm Subject Estimate Error Value Pr Z UN(,) ID <.000 UN(,) ID UN(,) ID <.000 UN(3,) ID UN(3,) ID <.000 UN(3,3) ID <.000 Session ID <.000 NegLogLike Parms AIC AICC HQIC BIC CAIC Effect Estimate Error DF t Value Pr > t Intercept <.000 csess <.000 RATE OF CHANGE FROM SESSION - Slope DIFFERENCE IN RATE OF CHANGE FROM SESSION -6 Estimates Label Estimate Error DF t Value Pr > t Slope from session <.000

19 Random Effect 95% CI = fixed effect ±.96* Random Variance 0 Intercept 95% CI = γ ±.96* τ,96.9 ±.96* 84,3 = 97 to 3, U Slope6 95% CI = γ ±.96* τ 63.6 ±.96* 63,954 = 659 to 3 0 U Slope6 95% CI = γ ±.96* τ 30.8 ±.96* 69,96 = 338 to U Psyc 945 Example page 9 So how did we do? Let s compare model predictions in terms of means (top) and variances (bottom)?,000 Predicted Means by Session by Model (from REML),900 Response Time (milliseconds),800,700 Saturated Means, Unstructured Variance (Model 0) Random Quadratic Time (Model 3b),600,500 35, , Session Piecewise Slope and Slope6 (Model 4c) Predicted Total Variance by Session by Model (from REML) See Hoffman chapter 6 for an example results section and complete description of these models, as well as a negative exponential model for these data. Response Time (milliseconds) 75,000 50,000 5,000 Saturated Means, Unstructured Variance (Model 0) Random Quadratic Time (Model 3b) Random Slope -, Fixed Slope -6 (Model 4b) 00,000 Random Slope -, Random Slope -6 (Model 4c) 75, Session

SAS Syntax and Output for Data Manipulation:

SAS Syntax and Output for Data Manipulation: CLP 944 Example 5 page 1 Practice with Fixed and Random Effects of Time in Modeling Within-Person Change The models for this example come from Hoffman (2015) chapter 5. We will be examining the extent

More information

ANOVA Longitudinal Models for the Practice Effects Data: via GLM

ANOVA Longitudinal Models for the Practice Effects Data: via GLM Psyc 943 Lecture 25 page 1 ANOVA Longitudinal Models for the Practice Effects Data: via GLM Model 1. Saturated Means Model for Session, E-only Variances Model (BP) Variances Model: NO correlation, EQUAL

More information

over Time line for the means). Specifically, & covariances) just a fixed variance instead. PROC MIXED: to 1000 is default) list models with TYPE=VC */

over Time line for the means). Specifically, & covariances) just a fixed variance instead. PROC MIXED: to 1000 is default) list models with TYPE=VC */ CLP 944 Example 4 page 1 Within-Personn Fluctuation in Symptom Severity over Time These data come from a study of weekly fluctuation in psoriasis severity. There was no intervention and no real reason

More information

SAS Syntax and Output for Data Manipulation: CLDP 944 Example 3a page 1

SAS Syntax and Output for Data Manipulation: CLDP 944 Example 3a page 1 CLDP 944 Example 3a page 1 From Between-Person to Within-Person Models for Longitudinal Data The models for this example come from Hoffman (2015) chapter 3 example 3a. We will be examining the extent to

More information

Example 7b: Generalized Models for Ordinal Longitudinal Data using SAS GLIMMIX, STATA MEOLOGIT, and MPLUS (last proportional odds model only)

Example 7b: Generalized Models for Ordinal Longitudinal Data using SAS GLIMMIX, STATA MEOLOGIT, and MPLUS (last proportional odds model only) CLDP945 Example 7b page 1 Example 7b: Generalized Models for Ordinal Longitudinal Data using SAS GLIMMIX, STATA MEOLOGIT, and MPLUS (last proportional odds model only) This example comes from real data

More information

Review of CLDP 944: Multilevel Models for Longitudinal Data

Review of CLDP 944: Multilevel Models for Longitudinal Data Review of CLDP 944: Multilevel Models for Longitudinal Data Topics: Review of general MLM concepts and terminology Model comparisons and significance testing Fixed and random effects of time Significance

More information

Introduction to Within-Person Analysis and RM ANOVA

Introduction to Within-Person Analysis and RM ANOVA Introduction to Within-Person Analysis and RM ANOVA Today s Class: From between-person to within-person ANOVAs for longitudinal data Variance model comparisons using 2 LL CLP 944: Lecture 3 1 The Two Sides

More information

Subject-specific observed profiles of log(fev1) vs age First 50 subjects in Six Cities Study

Subject-specific observed profiles of log(fev1) vs age First 50 subjects in Six Cities Study Subject-specific observed profiles of log(fev1) vs age First 50 subjects in Six Cities Study 1.4 0.0-6 7 8 9 10 11 12 13 14 15 16 17 18 19 age Model 1: A simple broken stick model with knot at 14 fit with

More information

Independence (Null) Baseline Model: Item means and variances, but NO covariances

Independence (Null) Baseline Model: Item means and variances, but NO covariances CFA Example Using Forgiveness of Situations (N = 1103) using SAS MIXED (See Example 4 for corresponding Mplus syntax and output) SAS Code to Read in Mplus Data: * Import data from Mplus, becomes var1-var23

More information

Introduction to SAS proc mixed

Introduction to SAS proc mixed Faculty of Health Sciences Introduction to SAS proc mixed Analysis of repeated measurements, 2017 Julie Forman Department of Biostatistics, University of Copenhagen Outline Data in wide and long format

More information

Random Coefficient Model (a.k.a. multilevel model) (Adapted from UCLA Statistical Computing Seminars)

Random Coefficient Model (a.k.a. multilevel model) (Adapted from UCLA Statistical Computing Seminars) STAT:5201 Applied Statistic II Random Coefficient Model (a.k.a. multilevel model) (Adapted from UCLA Statistical Computing Seminars) School math achievement scores The data file consists of 7185 students

More information

Designing Multilevel Models Using SPSS 11.5 Mixed Model. John Painter, Ph.D.

Designing Multilevel Models Using SPSS 11.5 Mixed Model. John Painter, Ph.D. Designing Multilevel Models Using SPSS 11.5 Mixed Model John Painter, Ph.D. Jordan Institute for Families School of Social Work University of North Carolina at Chapel Hill 1 Creating Multilevel Models

More information

Testing Indirect Effects for Lower Level Mediation Models in SAS PROC MIXED

Testing Indirect Effects for Lower Level Mediation Models in SAS PROC MIXED Testing Indirect Effects for Lower Level Mediation Models in SAS PROC MIXED Here we provide syntax for fitting the lower-level mediation model using the MIXED procedure in SAS as well as a sas macro, IndTest.sas

More information

Introduction to Random Effects of Time and Model Estimation

Introduction to Random Effects of Time and Model Estimation Introduction to Random Effects of Time and Model Estimation Today s Class: The Big Picture Multilevel model notation Fixed vs. random effects of time Random intercept vs. random slope models How MLM =

More information

Describing Within-Person Fluctuation over Time using Alternative Covariance Structures

Describing Within-Person Fluctuation over Time using Alternative Covariance Structures Describing Within-Person Fluctuation over Time using Alternative Covariance Structures Today s Class: The Big Picture ACS models using the R matrix only Introducing the G, Z, and V matrices ACS models

More information

Lab 11. Multilevel Models. Description of Data

Lab 11. Multilevel Models. Description of Data Lab 11 Multilevel Models Henian Chen, M.D., Ph.D. Description of Data MULTILEVEL.TXT is clustered data for 386 women distributed across 40 groups. ID: 386 women, id from 1 to 386, individual level (level

More information

Describing Within-Person Change over Time

Describing Within-Person Change over Time Describing Within-Person Change over Time Topics: Multilevel modeling notation and terminology Fixed and random effects of linear time Predicted variances and covariances from random slopes Dependency

More information

MIXED MODELS FOR REPEATED (LONGITUDINAL) DATA PART 2 DAVID C. HOWELL 4/1/2010

MIXED MODELS FOR REPEATED (LONGITUDINAL) DATA PART 2 DAVID C. HOWELL 4/1/2010 MIXED MODELS FOR REPEATED (LONGITUDINAL) DATA PART 2 DAVID C. HOWELL 4/1/2010 Part 1 of this document can be found at http://www.uvm.edu/~dhowell/methods/supplements/mixed Models for Repeated Measures1.pdf

More information

Introduction to SAS proc mixed

Introduction to SAS proc mixed Faculty of Health Sciences Introduction to SAS proc mixed Analysis of repeated measurements, 2017 Julie Forman Department of Biostatistics, University of Copenhagen 2 / 28 Preparing data for analysis The

More information

Practice with Interactions among Continuous Predictors in General Linear Models (as estimated using restricted maximum likelihood in SAS MIXED)

Practice with Interactions among Continuous Predictors in General Linear Models (as estimated using restricted maximum likelihood in SAS MIXED) CLP 944 Example 2b page 1 Practice with Interactions among Continuous Predictors in General Linear Models (as estimated using restricted maximum likelihood in SAS MIXED) The models for this example come

More information

Answer to exercise: Blood pressure lowering drugs

Answer to exercise: Blood pressure lowering drugs Answer to exercise: Blood pressure lowering drugs The data set bloodpressure.txt contains data from a cross-over trial, involving three different formulations of a drug for lowering of blood pressure:

More information

Describing Change over Time: Adding Linear Trends

Describing Change over Time: Adding Linear Trends Describing Change over Time: Adding Linear Trends Longitudinal Data Analysis Workshop Section 7 University of Georgia: Institute for Interdisciplinary Research in Education and Human Development Section

More information

Review of Unconditional Multilevel Models for Longitudinal Data

Review of Unconditional Multilevel Models for Longitudinal Data Review of Unconditional Multilevel Models for Longitudinal Data Topics: Course (and MLM) overview Concepts in longitudinal multilevel modeling Model comparisons and significance testing Describing within-person

More information

Describing Nonlinear Change Over Time

Describing Nonlinear Change Over Time Describing Nonlinear Change Over Time Longitudinal Data Analysis Workshop Section 8 University of Georgia: Institute for Interdisciplinary Research in Education and Human Development Section 8: Describing

More information

Covariance Structure Approach to Within-Cases

Covariance Structure Approach to Within-Cases Covariance Structure Approach to Within-Cases Remember how the data file grapefruit1.data looks: Store sales1 sales2 sales3 1 62.1 61.3 60.8 2 58.2 57.9 55.1 3 51.6 49.2 46.2 4 53.7 51.5 48.3 5 61.4 58.7

More information

Interactions among Continuous Predictors

Interactions among Continuous Predictors Interactions among Continuous Predictors Today s Class: Simple main effects within two-way interactions Conquering TEST/ESTIMATE/LINCOM statements Regions of significance Three-way interactions (and beyond

More information

Simple, Marginal, and Interaction Effects in General Linear Models: Part 1

Simple, Marginal, and Interaction Effects in General Linear Models: Part 1 Simple, Marginal, and Interaction Effects in General Linear Models: Part 1 PSYC 943 (930): Fundamentals of Multivariate Modeling Lecture 2: August 24, 2012 PSYC 943: Lecture 2 Today s Class Centering and

More information

An Introduction to Multilevel Models. PSYC 943 (930): Fundamentals of Multivariate Modeling Lecture 25: December 7, 2012

An Introduction to Multilevel Models. PSYC 943 (930): Fundamentals of Multivariate Modeling Lecture 25: December 7, 2012 An Introduction to Multilevel Models PSYC 943 (930): Fundamentals of Multivariate Modeling Lecture 25: December 7, 2012 Today s Class Concepts in Longitudinal Modeling Between-Person vs. +Within-Person

More information

Interactions among Categorical Predictors

Interactions among Categorical Predictors Interactions among Categorical Predictors Today s Class: Reviewing significance tests Manual contrasts for categorical predictors Program-created contrasts for categorical predictors SPLH 861: Lecture

More information

Time Invariant Predictors in Longitudinal Models

Time Invariant Predictors in Longitudinal Models Time Invariant Predictors in Longitudinal Models Longitudinal Data Analysis Workshop Section 9 University of Georgia: Institute for Interdisciplinary Research in Education and Human Development Section

More information

Time-Invariant Predictors in Longitudinal Models

Time-Invariant Predictors in Longitudinal Models Time-Invariant Predictors in Longitudinal Models Today s Class (or 3): Summary of steps in building unconditional models for time What happens to missing predictors Effects of time-invariant predictors

More information

A (Brief) Introduction to Crossed Random Effects Models for Repeated Measures Data

A (Brief) Introduction to Crossed Random Effects Models for Repeated Measures Data A (Brief) Introduction to Crossed Random Effects Models for Repeated Measures Data Today s Class: Review of concepts in multivariate data Introduction to random intercepts Crossed random effects models

More information

Longitudinal Data Analysis of Health Outcomes

Longitudinal Data Analysis of Health Outcomes Longitudinal Data Analysis of Health Outcomes Longitudinal Data Analysis Workshop Running Example: Days 2 and 3 University of Georgia: Institute for Interdisciplinary Research in Education and Human Development

More information

Models for longitudinal data

Models for longitudinal data Faculty of Health Sciences Contents Models for longitudinal data Analysis of repeated measurements, NFA 016 Julie Lyng Forman & Lene Theil Skovgaard Department of Biostatistics, University of Copenhagen

More information

Time-Invariant Predictors in Longitudinal Models

Time-Invariant Predictors in Longitudinal Models Time-Invariant Predictors in Longitudinal Models Topics: Summary of building unconditional models for time Missing predictors in MLM Effects of time-invariant predictors Fixed, systematically varying,

More information

Daniel J. Bauer & Patrick J. Curran

Daniel J. Bauer & Patrick J. Curran GET FILE='C:\Users\dan\Dropbox\SRA\antisocial.sav'. >Warning # 5281. Command name: GET FILE >SPSS Statistics is running in Unicode encoding mode. This file is encoded in >a locale-specific (code page)

More information

Repeated Measures ANOVA Multivariate ANOVA and Their Relationship to Linear Mixed Models

Repeated Measures ANOVA Multivariate ANOVA and Their Relationship to Linear Mixed Models Repeated Measures ANOVA Multivariate ANOVA and Their Relationship to Linear Mixed Models EPSY 905: Multivariate Analysis Spring 2016 Lecture #12 April 20, 2016 EPSY 905: RM ANOVA, MANOVA, and Mixed Models

More information

Review of Multilevel Models for Longitudinal Data

Review of Multilevel Models for Longitudinal Data Review of Multilevel Models for Longitudinal Data Topics: Concepts in longitudinal multilevel modeling Describing within-person fluctuation using ACS models Describing within-person change using random

More information

Contrasting Marginal and Mixed Effects Models Recall: two approaches to handling dependence in Generalized Linear Models:

Contrasting Marginal and Mixed Effects Models Recall: two approaches to handling dependence in Generalized Linear Models: Contrasting Marginal and Mixed Effects Models Recall: two approaches to handling dependence in Generalized Linear Models: Marginal models: based on the consequences of dependence on estimating model parameters.

More information

A Re-Introduction to General Linear Models (GLM)

A Re-Introduction to General Linear Models (GLM) A Re-Introduction to General Linear Models (GLM) Today s Class: You do know the GLM Estimation (where the numbers in the output come from): From least squares to restricted maximum likelihood (REML) Reviewing

More information

Correlated data. Repeated measurements over time. Typical set-up for repeated measurements. Traditional presentation of data

Correlated data. Repeated measurements over time. Typical set-up for repeated measurements. Traditional presentation of data Faculty of Health Sciences Repeated measurements over time Correlated data NFA, May 22, 2014 Longitudinal measurements Julie Lyng Forman & Lene Theil Skovgaard Department of Biostatistics University of

More information

Analysis of Longitudinal Data: Comparison Between PROC GLM and PROC MIXED. Maribeth Johnson Medical College of Georgia Augusta, GA

Analysis of Longitudinal Data: Comparison Between PROC GLM and PROC MIXED. Maribeth Johnson Medical College of Georgia Augusta, GA Analysis of Longitudinal Data: Comparison Between PROC GLM and PROC MIXED Maribeth Johnson Medical College of Georgia Augusta, GA Overview Introduction to longitudinal data Describe the data for examples

More information

Time-Invariant Predictors in Longitudinal Models

Time-Invariant Predictors in Longitudinal Models Time-Invariant Predictors in Longitudinal Models Topics: What happens to missing predictors Effects of time-invariant predictors Fixed vs. systematically varying vs. random effects Model building strategies

More information

STAT 5200 Handout #23. Repeated Measures Example (Ch. 16)

STAT 5200 Handout #23. Repeated Measures Example (Ch. 16) Motivating Example: Glucose STAT 500 Handout #3 Repeated Measures Example (Ch. 16) An experiment is conducted to evaluate the effects of three diets on the serum glucose levels of human subjects. Twelve

More information

Statistical Inference: The Marginal Model

Statistical Inference: The Marginal Model Statistical Inference: The Marginal Model Edps/Psych/Stat 587 Carolyn J. Anderson Department of Educational Psychology c Board of Trustees, University of Illinois Fall 2017 Outline Inference for fixed

More information

Step 2: Select Analyze, Mixed Models, and Linear.

Step 2: Select Analyze, Mixed Models, and Linear. Example 1a. 20 employees were given a mood questionnaire on Monday, Wednesday and again on Friday. The data will be first be analyzed using a Covariance Pattern model. Step 1: Copy Example1.sav data file

More information

Time-Invariant Predictors in Longitudinal Models

Time-Invariant Predictors in Longitudinal Models Time-Invariant Predictors in Longitudinal Models Today s Topics: What happens to missing predictors Effects of time-invariant predictors Fixed vs. systematically varying vs. random effects Model building

More information

Additional Notes: Investigating a Random Slope. When we have fixed level-1 predictors at level 2 we show them like this:

Additional Notes: Investigating a Random Slope. When we have fixed level-1 predictors at level 2 we show them like this: Ron Heck, Summer 01 Seminars 1 Multilevel Regression Models and Their Applications Seminar Additional Notes: Investigating a Random Slope We can begin with Model 3 and add a Random slope parameter. If

More information

UNIVERSITY OF TORONTO. Faculty of Arts and Science APRIL 2010 EXAMINATIONS STA 303 H1S / STA 1002 HS. Duration - 3 hours. Aids Allowed: Calculator

UNIVERSITY OF TORONTO. Faculty of Arts and Science APRIL 2010 EXAMINATIONS STA 303 H1S / STA 1002 HS. Duration - 3 hours. Aids Allowed: Calculator UNIVERSITY OF TORONTO Faculty of Arts and Science APRIL 2010 EXAMINATIONS STA 303 H1S / STA 1002 HS Duration - 3 hours Aids Allowed: Calculator LAST NAME: FIRST NAME: STUDENT NUMBER: There are 27 pages

More information

Analysis of variance and regression. May 13, 2008

Analysis of variance and regression. May 13, 2008 Analysis of variance and regression May 13, 2008 Repeated measurements over time Presentation of data Traditional ways of analysis Variance component model (the dogs revisited) Random regression Baseline

More information

Generalized Linear Models for Non-Normal Data

Generalized Linear Models for Non-Normal Data Generalized Linear Models for Non-Normal Data Today s Class: 3 parts of a generalized model Models for binary outcomes Complications for generalized multivariate or multilevel models SPLH 861: Lecture

More information

Longitudinal Data Analysis

Longitudinal Data Analysis Longitudinal Data Analysis Mike Allerhand This document has been produced for the CCACE short course: Longitudinal Data Analysis. No part of this document may be reproduced, in any form or by any means,

More information

36-309/749 Experimental Design for Behavioral and Social Sciences. Dec 1, 2015 Lecture 11: Mixed Models (HLMs)

36-309/749 Experimental Design for Behavioral and Social Sciences. Dec 1, 2015 Lecture 11: Mixed Models (HLMs) 36-309/749 Experimental Design for Behavioral and Social Sciences Dec 1, 2015 Lecture 11: Mixed Models (HLMs) Independent Errors Assumption An error is the deviation of an individual observed outcome (DV)

More information

Repeated Measures Design. Advertising Sales Example

Repeated Measures Design. Advertising Sales Example STAT:5201 Anaylsis/Applied Statistic II Repeated Measures Design Advertising Sales Example A company is interested in comparing the success of two different advertising campaigns. It has 10 test markets,

More information

Topic 23: Diagnostics and Remedies

Topic 23: Diagnostics and Remedies Topic 23: Diagnostics and Remedies Outline Diagnostics residual checks ANOVA remedial measures Diagnostics Overview We will take the diagnostics and remedial measures that we learned for regression and

More information

Topic 17 - Single Factor Analysis of Variance. Outline. One-way ANOVA. The Data / Notation. One way ANOVA Cell means model Factor effects model

Topic 17 - Single Factor Analysis of Variance. Outline. One-way ANOVA. The Data / Notation. One way ANOVA Cell means model Factor effects model Topic 17 - Single Factor Analysis of Variance - Fall 2013 One way ANOVA Cell means model Factor effects model Outline Topic 17 2 One-way ANOVA Response variable Y is continuous Explanatory variable is

More information

Repeated Measures Data

Repeated Measures Data Repeated Measures Data Mixed Models Lecture Notes By Dr. Hanford page 1 Data where subjects are measured repeatedly over time - predetermined intervals (weekly) - uncontrolled variable intervals between

More information

Random Intercept Models

Random Intercept Models Random Intercept Models Edps/Psych/Soc 589 Carolyn J. Anderson Department of Educational Psychology c Board of Trustees, University of Illinois Spring 2019 Outline A very simple case of a random intercept

More information

Correlated data. Longitudinal data. Typical set-up for repeated measurements. Examples from literature, I. Faculty of Health Sciences

Correlated data. Longitudinal data. Typical set-up for repeated measurements. Examples from literature, I. Faculty of Health Sciences Faculty of Health Sciences Longitudinal data Correlated data Longitudinal measurements Outline Designs Models for the mean Covariance patterns Lene Theil Skovgaard November 27, 2015 Random regression Baseline

More information

Statistical Analysis of Hierarchical Data. David Zucker Hebrew University, Jerusalem, Israel

Statistical Analysis of Hierarchical Data. David Zucker Hebrew University, Jerusalem, Israel Statistical Analysis of Hierarchical Data David Zucker Hebrew University, Jerusalem, Israel Unit 1 Linear Mixed Models 1 Examples of Hierarchical Data Hierarchical data = subunits within units Students

More information

Mixed Models for Longitudinal Binary Outcomes. Don Hedeker Department of Public Health Sciences University of Chicago.

Mixed Models for Longitudinal Binary Outcomes. Don Hedeker Department of Public Health Sciences University of Chicago. Mixed Models for Longitudinal Binary Outcomes Don Hedeker Department of Public Health Sciences University of Chicago hedeker@uchicago.edu https://hedeker-sites.uchicago.edu/ Hedeker, D. (2005). Generalized

More information

Supplemental Materials. In the main text, we recommend graphing physiological values for individual dyad

Supplemental Materials. In the main text, we recommend graphing physiological values for individual dyad 1 Supplemental Materials Graphing Values for Individual Dyad Members over Time In the main text, we recommend graphing physiological values for individual dyad members over time to aid in the decision

More information

Repeated Measures Modeling With PROC MIXED E. Barry Moser, Louisiana State University, Baton Rouge, LA

Repeated Measures Modeling With PROC MIXED E. Barry Moser, Louisiana State University, Baton Rouge, LA Paper 188-29 Repeated Measures Modeling With PROC MIXED E. Barry Moser, Louisiana State University, Baton Rouge, LA ABSTRACT PROC MIXED provides a very flexible environment in which to model many types

More information

Lecture 4. Random Effects in Completely Randomized Design

Lecture 4. Random Effects in Completely Randomized Design Lecture 4. Random Effects in Completely Randomized Design Montgomery: 3.9, 13.1 and 13.7 1 Lecture 4 Page 1 Random Effects vs Fixed Effects Consider factor with numerous possible levels Want to draw inference

More information

Simple, Marginal, and Interaction Effects in General Linear Models

Simple, Marginal, and Interaction Effects in General Linear Models Simple, Marginal, and Interaction Effects in General Linear Models PRE 905: Multivariate Analysis Lecture 3 Today s Class Centering and Coding Predictors Interpreting Parameters in the Model for the Means

More information

36-402/608 Homework #10 Solutions 4/1

36-402/608 Homework #10 Solutions 4/1 36-402/608 Homework #10 Solutions 4/1 1. Fixing Breakout 17 (60 points) You must use SAS for this problem! Modify the code in wallaby.sas to load the wallaby data and to create a new outcome in the form

More information

Multilevel/Mixed Models and Longitudinal Analysis Using Stata

Multilevel/Mixed Models and Longitudinal Analysis Using Stata Multilevel/Mixed Models and Longitudinal Analysis Using Stata Isaac J. Washburn PhD Research Associate Oregon Social Learning Center Summer Workshop Series July 2010 Longitudinal Analysis 1 Longitudinal

More information

Missing Data in Longitudinal Studies: Mixed-effects Pattern-Mixture and Selection Models

Missing Data in Longitudinal Studies: Mixed-effects Pattern-Mixture and Selection Models Missing Data in Longitudinal Studies: Mixed-effects Pattern-Mixture and Selection Models Hedeker D & Gibbons RD (1997). Application of random-effects pattern-mixture models for missing data in longitudinal

More information

Mixed Effects Models

Mixed Effects Models Mixed Effects Models What is the effect of X on Y What is the effect of an independent variable on the dependent variable Independent variables are fixed factors. We want to measure their effect Random

More information

Topic 20: Single Factor Analysis of Variance

Topic 20: Single Factor Analysis of Variance Topic 20: Single Factor Analysis of Variance Outline Single factor Analysis of Variance One set of treatments Cell means model Factor effects model Link to linear regression using indicator explanatory

More information

Biostatistics Workshop Longitudinal Data Analysis. Session 4 GARRETT FITZMAURICE

Biostatistics Workshop Longitudinal Data Analysis. Session 4 GARRETT FITZMAURICE Biostatistics Workshop 2008 Longitudinal Data Analysis Session 4 GARRETT FITZMAURICE Harvard University 1 LINEAR MIXED EFFECTS MODELS Motivating Example: Influence of Menarche on Changes in Body Fat Prospective

More information

Hierarchical Generalized Linear Models. ERSH 8990 REMS Seminar on HLM Last Lecture!

Hierarchical Generalized Linear Models. ERSH 8990 REMS Seminar on HLM Last Lecture! Hierarchical Generalized Linear Models ERSH 8990 REMS Seminar on HLM Last Lecture! Hierarchical Generalized Linear Models Introduction to generalized models Models for binary outcomes Interpreting parameter

More information

Course Introduction and Overview Descriptive Statistics Conceptualizations of Variance Review of the General Linear Model

Course Introduction and Overview Descriptive Statistics Conceptualizations of Variance Review of the General Linear Model Course Introduction and Overview Descriptive Statistics Conceptualizations of Variance Review of the General Linear Model PSYC 943 (930): Fundamentals of Multivariate Modeling Lecture 1: August 22, 2012

More information

Variance components and LMMs

Variance components and LMMs Faculty of Health Sciences Variance components and LMMs Analysis of repeated measurements, 4th December 2014 Julie Lyng Forman & Lene Theil Skovgaard Department of Biostatistics, University of Copenhagen

More information

Statistical Distribution Assumptions of General Linear Models

Statistical Distribution Assumptions of General Linear Models Statistical Distribution Assumptions of General Linear Models Applied Multilevel Models for Cross Sectional Data Lecture 4 ICPSR Summer Workshop University of Colorado Boulder Lecture 4: Statistical Distributions

More information

Variance components and LMMs

Variance components and LMMs Faculty of Health Sciences Topics for today Variance components and LMMs Analysis of repeated measurements, 4th December 04 Leftover from 8/: Rest of random regression example. New concepts for today:

More information

dm'log;clear;output;clear'; options ps=512 ls=99 nocenter nodate nonumber nolabel FORMCHAR=" = -/\<>*"; ODS LISTING;

dm'log;clear;output;clear'; options ps=512 ls=99 nocenter nodate nonumber nolabel FORMCHAR= = -/\<>*; ODS LISTING; dm'log;clear;output;clear'; options ps=512 ls=99 nocenter nodate nonumber nolabel FORMCHAR=" ---- + ---+= -/\*"; ODS LISTING; *** Table 23.2 ********************************************; *** Moore, David

More information

17. Example SAS Commands for Analysis of a Classic Split-Plot Experiment 17. 1

17. Example SAS Commands for Analysis of a Classic Split-Plot Experiment 17. 1 17 Example SAS Commands for Analysis of a Classic SplitPlot Experiment 17 1 DELIMITED options nocenter nonumber nodate ls80; Format SCREEN OUTPUT proc import datafile"c:\data\simulatedsplitplotdatatxt"

More information

Changes Report 2: Examples from the Australian Longitudinal Study on Women s Health for Analysing Longitudinal Data

Changes Report 2: Examples from the Australian Longitudinal Study on Women s Health for Analysing Longitudinal Data ChangesReport: ExamplesfromtheAustralianLongitudinal StudyonWomen shealthforanalysing LongitudinalData June005 AustralianLongitudinalStudyonWomen shealth ReporttotheDepartmentofHealthandAgeing ThisreportisbasedonthecollectiveworkoftheStatisticsGroupoftheAustralianLongitudinal

More information

A Re-Introduction to General Linear Models

A Re-Introduction to General Linear Models A Re-Introduction to General Linear Models Today s Class: Big picture overview Why we are using restricted maximum likelihood within MIXED instead of least squares within GLM Linear model interpretation

More information

Serial Correlation. Edps/Psych/Stat 587. Carolyn J. Anderson. Fall Department of Educational Psychology

Serial Correlation. Edps/Psych/Stat 587. Carolyn J. Anderson. Fall Department of Educational Psychology Serial Correlation Edps/Psych/Stat 587 Carolyn J. Anderson Department of Educational Psychology c Board of Trustees, University of Illinois Fall 017 Model for Level 1 Residuals There are three sources

More information

MLMED. User Guide. Nicholas J. Rockwood The Ohio State University Beta Version May, 2017

MLMED. User Guide. Nicholas J. Rockwood The Ohio State University Beta Version May, 2017 MLMED User Guide Nicholas J. Rockwood The Ohio State University rockwood.19@osu.edu Beta Version May, 2017 MLmed is a computational macro for SPSS that simplifies the fitting of multilevel mediation and

More information

Class Notes: Week 8. Probit versus Logit Link Functions and Count Data

Class Notes: Week 8. Probit versus Logit Link Functions and Count Data Ronald Heck Class Notes: Week 8 1 Class Notes: Week 8 Probit versus Logit Link Functions and Count Data This week we ll take up a couple of issues. The first is working with a probit link function. While

More information

STAT 705 Generalized linear mixed models

STAT 705 Generalized linear mixed models STAT 705 Generalized linear mixed models Timothy Hanson Department of Statistics, University of South Carolina Stat 705: Data Analysis II 1 / 24 Generalized Linear Mixed Models We have considered random

More information

Longitudinal Modeling with Logistic Regression

Longitudinal Modeling with Logistic Regression Newsom 1 Longitudinal Modeling with Logistic Regression Longitudinal designs involve repeated measurements of the same individuals over time There are two general classes of analyses that correspond to

More information

Random Coefficients Model Examples

Random Coefficients Model Examples Random Coefficients Model Examples STAT:5201 Week 15 - Lecture 2 1 / 26 Each subject (or experimental unit) has multiple measurements (this could be over time, or it could be multiple measurements on a

More information

Topic 25 - One-Way Random Effects Models. Outline. Random Effects vs Fixed Effects. Data for One-way Random Effects Model. One-way Random effects

Topic 25 - One-Way Random Effects Models. Outline. Random Effects vs Fixed Effects. Data for One-way Random Effects Model. One-way Random effects Topic 5 - One-Way Random Effects Models One-way Random effects Outline Model Variance component estimation - Fall 013 Confidence intervals Topic 5 Random Effects vs Fixed Effects Consider factor with numerous

More information

Variance component models part I

Variance component models part I Faculty of Health Sciences Variance component models part I Analysis of repeated measurements, 30th November 2012 Julie Lyng Forman & Lene Theil Skovgaard Department of Biostatistics, University of Copenhagen

More information

Advantages of Mixed-effects Regression Models (MRM; aka multilevel, hierarchical linear, linear mixed models) 1. MRM explicitly models individual

Advantages of Mixed-effects Regression Models (MRM; aka multilevel, hierarchical linear, linear mixed models) 1. MRM explicitly models individual Advantages of Mixed-effects Regression Models (MRM; aka multilevel, hierarchical linear, linear mixed models) 1. MRM explicitly models individual change across time 2. MRM more flexible in terms of repeated

More information

Faculty of Health Sciences. Correlated data. Variance component models. Lene Theil Skovgaard & Julie Lyng Forman.

Faculty of Health Sciences. Correlated data. Variance component models. Lene Theil Skovgaard & Julie Lyng Forman. Faculty of Health Sciences Correlated data Variance component models Lene Theil Skovgaard & Julie Lyng Forman November 27, 2018 1 / 84 Overview One-way anova with random variation The rabbit example Hierarchical

More information

Correlated data. Overview. Example: Swelling due to vaccine. Variance component models. Faculty of Health Sciences. Variance component models

Correlated data. Overview. Example: Swelling due to vaccine. Variance component models. Faculty of Health Sciences. Variance component models Faculty of Health Sciences Overview Correlated data Variance component models One-way anova with random variation The rabbit example Hierarchical models with several levels Random regression Lene Theil

More information

MULTILEVEL MODELS. Multilevel-analysis in SPSS - step by step

MULTILEVEL MODELS. Multilevel-analysis in SPSS - step by step MULTILEVEL MODELS Multilevel-analysis in SPSS - step by step Dimitri Mortelmans Centre for Longitudinal and Life Course Studies (CLLS) University of Antwerp Overview of a strategy. Data preparation (centering

More information

Random Effects. Edps/Psych/Stat 587. Carolyn J. Anderson. Fall Department of Educational Psychology. university of illinois at urbana-champaign

Random Effects. Edps/Psych/Stat 587. Carolyn J. Anderson. Fall Department of Educational Psychology. university of illinois at urbana-champaign Random Effects Edps/Psych/Stat 587 Carolyn J. Anderson Department of Educational Psychology I L L I N O I S university of illinois at urbana-champaign Fall 2012 Outline Introduction Empirical Bayes inference

More information

Linear mixed models. Faculty of Health Sciences. Analysis of repeated measurements, 10th March Julie Lyng Forman & Lene Theil Skovgaard

Linear mixed models. Faculty of Health Sciences. Analysis of repeated measurements, 10th March Julie Lyng Forman & Lene Theil Skovgaard Faculty of Health Sciences Linear mixed models Analysis of repeated measurements, 10th March 2015 Julie Lyng Forman & Lene Theil Skovgaard Department of Biostatistics, University of Copenhagen 1 / 80 Program

More information

Implementation of Pairwise Fitting Technique for Analyzing Multivariate Longitudinal Data in SAS

Implementation of Pairwise Fitting Technique for Analyzing Multivariate Longitudinal Data in SAS PharmaSUG2011 - Paper SP09 Implementation of Pairwise Fitting Technique for Analyzing Multivariate Longitudinal Data in SAS Madan Gopal Kundu, Indiana University Purdue University at Indianapolis, Indianapolis,

More information

Generalized Models: Part 1

Generalized Models: Part 1 Generalized Models: Part 1 Topics: Introduction to generalized models Introduction to maximum likelihood estimation Models for binary outcomes Models for proportion outcomes Models for categorical outcomes

More information

Analyzing the Behavior of Rats by Repeated Measurements

Analyzing the Behavior of Rats by Repeated Measurements Georgia State University ScholarWorks @ Georgia State University Mathematics Theses Department of Mathematics and Statistics 5-3-007 Analyzing the Behavior of Rats by Repeated Measurements Kenita A. Hall

More information

Linear Mixed Models with Repeated Effects

Linear Mixed Models with Repeated Effects 1 Linear Mixed Models with Repeated Effects Introduction and Examples Using SAS/STAT Software Jerry W. Davis, University of Georgia, Griffin Campus. Introduction Repeated measures refer to measurements

More information

Two-Level Models for Clustered* Data

Two-Level Models for Clustered* Data Two-Level Models for Clustered* Data Today s Class: Fixed vs. Random Effects for Modeling Clustered Data ICC and Design Effects in Clustered Data Group-Mean-Centering vs. Grand-Mean Centering Model Extensions

More information

Multi-factor analysis of variance

Multi-factor analysis of variance Faculty of Health Sciences Outline Multi-factor analysis of variance Basic statistics for experimental researchers 2015 Two-way ANOVA and interaction Mathed samples ANOVA Random vs systematic variation

More information