Repeated Measures Models Stat 557 Heike Hofmann Big 12 - 2012 • with 17 games still missing ... • can’t estimate home advantage (Kansas State hasn’t lost yet, Kansas hasn’t won) Outline • Marginal Homogeneity • additional covariates • general log-linear models Repeated Measures Models • Extension of matched pairs data • Multiple (T ≥ 3) measurements observed for same individual, e.g. individuals’ weekly progress • Measurements for cluster of individuals (T ≥ 3), e.g. one litter, teeth at dentist’s visit, ... If β1 = β2 = ... = βT = 0 we observe marginal homogeneity, i.e. t P (YT = 1). Example: Drug Comparisons Example: Crossover-Study of Drugs Drugs A, B, and C are t disease in a cross-over study, i.e. each individual is treated for some binary: (success/failure) for each drug, giving a data set of • Cross-over effect of drugs A, B, C • Interested in marginal distributions P(A=S), P(B=S), P(C=S) A B S S S S S F S F F S F S F F F F Total C S F S F S F S F count 6 16 2 4 2 4 6 6 46 One question of interest for these data is, whether all of the drugs are difference. This question translates to whether marginal homogeneity From the raw data we get estimates for the effectiveness of each drug 8 Repeated Response Data d ResponseMultiple 8 Data Repeated Response D Binary A lot of repeatedly, studies observe individuals repeatedly, e.g. rve individuals e.g. longitudinal studies. A data lot of studies observe individuals rep For these we will be mainly interested in the ill be mainly interested in the marginal distributions. For these data we will be mainly intere Let (Y , Y , ...., Y ) be a tuple of binary response va 1 2 T be a tuple of binary response variables observed at (time) po Let (Y1 , Yin , ...., Y ) points be of We Yare interested the probability of for e response for time t=1, ..., T binary t binary 2for Tt, the probability of success each i.e. awetuple aresuccess interested A as logit model is interested then definedinasthe probability of We are n defined logit model logit P (Yt A logit is 1) then logitmodel P (Yt = = αdefined + βt , as estimability: with constraint βT = 0 (or α = 0). = 0 (or α = 0). = β2 =marginal ... = βThomogeneity, = 0 we observe marginal h 1observe βT = 0 IfweβMarginal i.e. then P (Y withhomogeneity constraint βT = 0 (or α = 0). 1 P (YT = 1). Response • • • If β1 = β2 = ... = βT = 0 we observe P (Y = 1). T Example: Crossover-Study of Drugs Drugs ver-Study of Drugs Drugs A, B, and C are tested on 4 disease in a individual cross-over isstudy, i.e.foreach individual er study, i.e. each treated some time wit Drugs Crossover > head(drugs.m) count id variable value 1 6 1 A Y 2 16 2 A Y 3 2 3 A Y 4 4 4 A Y 5 2 5 A N 6 4 6 A N glm(formula = value ~ variable - 1, family = binomial(link = logit), data = drugsm, weights = count) Deviance Residuals: Min 1Q Median -3.698 -2.740 -0.220 Drugs Crossover 3Q 2.152 Max 3.986 Coefficients: Estimate Std. Error z value Pr(>|z|) variableA 0.4418 0.3021 1.462 0.1436 variableB 0.4418 0.3021 1.462 0.1436 variableC -0.6286 0.3096 -2.031 0.0423 * --Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 191.31 Residual deviance: 182.60 AIC: 188.60 on 24 on 21 degrees of freedom degrees of freedom Number of Fisher Scoring iterations: 4 Marginal Homogeneity > anova(drugs.null, drugs.mh, test="Chisq") Analysis of Deviance Table Model 1: value ~ 1 Model 2: value ~ variable - 1 Resid. Df Resid. Dev Df Deviance P(>|Chi|) 1 23 191.05 2 21 182.60 2 8.451 0.01462 * --Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Longitudinal Mental Depression • study followed subjects over 4 week period • measurements taken at baseline, and after 1,2, and 4 weeks: Normal/Abnormal mental state • Additionally recorded: treatment (randomly assigned at baseline) severity (mild or severe) Longitudinal Mental Depression 1 2 3 4 diagnosis treatment N_N_N N_N_A N_A_N N_A_A A_N_N A_N_A A_A_N A_A_A mild standard 16 13 9 3 14 4 15 6 mild new drug 31 0 6 0 22 2 9 0 severe standard 2 2 8 9 9 15 27 38 severe new drug 7 2 5 2 31 5 32 6 Treatment Effects: Percentage of “normal” 1 2 3 4 diagnosis treatment week1 week2 week4 mild standard 51.25000 58.75000 67.50000 mild new drug 52.85714 78.57143 97.14286 severe standard 19.09091 25.45455 41.81818 severe new drug 17.77778 50.00000 83.33333 Marginal Model logit P (Yt = 1) = α + β1 s + β2 d + β3 t • s = 1 for severe cases • d = 1 for new drug • t = 0,1,2 week (log of actual treatment 2 time) Data treatment diagnosis lweek normal abnormal 1 standard mild 0 41 39 2 standard mild 1 47 33 3 standard mild 2 54 26 4 standard severe 0 21 89 5 standard severe 1 28 82 6 standard severe 2 46 64 7 new drug mild 0 37 33 8 new drug mild 1 55 15 9 new drug mild 2 68 2 10 new drug severe 0 16 74 11 new drug severe 1 45 45 12 new drug severe 2 75 15 12 Binomials Model depress.main.sm <- glm(cbind(normal,abnormal)~diagnosis+treatment+lweek, data=depress.sm, family=binomial(link=logit)) Data 1 2 3 4 diagnosis treatment N_N_N N_N_A N_A_N N_A_A A_N_N A_N_A A_A_N A_A_A mild standard 16 13 9 3 14 4 15 6 mild new drug 31 0 6 0 22 2 9 0 severe standard 2 2 8 9 9 15 27 38 severe new drug 7 2 5 2 31 5 32 6 4 Multinomials Model depress.main.sm <- glm(cbind(normal,abnormal)~diagnosis+treatment+lweek, data=depress.sm, family=binomial(link=logit)) glm(formula = cbind(normal, abnormal) ~ diagnosis + treatment + lweek, family = binomial(link = logit), data = depress.sm) Deviance Residuals: Min 1Q Median -2.4263 -1.2754 -0.1555 3Q 1.8274 Max 2.8076 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) -0.50671 0.14605 -3.470 0.000521 *** diagnosissevere -1.36798 0.14457 -9.462 < 2e-16 *** treatmentnew drug 0.97070 0.14156 6.857 7.03e-12 *** lweek 0.88920 0.08939 9.947 < 2e-16 *** --Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 275.760 Residual deviance: 36.314 AIC: 98.727 on 11 on 8 degrees of freedom degrees of freedom Number of Fisher Scoring iterations: 4 Model Interaction logit P (Yt = 1) = α + β1 s + β2 d + β3 t + β4 dt depress.two.sm <- glm(cbind(normal,abnormal)~diagnosis+treatment*lweek, data=depress.sm, family=binomial(link=logit)) Analysis of Deviance Table Model 1: cbind(normal, abnormal) ~ Model 2: cbind(normal, abnormal) ~ Resid. Df Resid. Dev Df Deviance 1 8 36.314 2 7 3.433 1 32.881 --Signif. codes: 0 ‘***’ 0.001 ‘**’ diagnosis + treatment + lweek diagnosis + treatment * lweek P(>|Chi|) 9.797e-09 *** 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 glm(formula = cbind(normal, abnormal) ~ diagnosis + treatment * lweek, family = binomial(link = logit), data = depress.sm) Deviance Residuals: Min 1Q Median -0.6792 -0.3597 -0.1609 3Q 0.4793 Max 0.8948 Coefficients: Estimate Std. Error z value (Intercept) -0.042175 0.163022 -0.259 diagnosissevere -1.398773 0.145777 -9.595 treatmentnew drug -0.006181 0.221929 -0.028 lweek 0.468408 0.112983 4.146 treatmentnew drug:lweek 1.046819 0.188310 5.559 --Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ Pr(>|z|) 0.796 < 2e-16 *** 0.978 3.39e-05 *** 2.71e-08 *** 0.1 ‘ ’ 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 275.7599 Residual deviance: 3.4329 AIC: 67.846 on 11 on 7 degrees of freedom degrees of freedom Number of Fisher Scoring iterations: 3 Difference between Agresti and our fit: > subset(depress, (treatment=="standard") &(diagnosis=="mild")) week4 week2 week1 treatment diagnosis count 1 N N N standard mild 16 2 A N N standard mild 13 3 N A N standard mild 9 4 A A N standard mild 3 5 N N A standard mild 14 6 A N A standard mild 4 7 N A A standard mild 15 8 A A A standard mild 6 overall n = 80 > subset(depress.sm, (treatment=="standard") &(diagnosis=="mild")) treatment diagnosis lweek normal abnormal n 1 standard mild 0 41 39 80 2 standard mild 1 47 33 80 3 standard mild 2 54 26 80 overall n = 240 Generalized Log-Linear Models • Extend concept of log-linear model: log µ = Xβ C log Aµ = Xβ • regular loglinear models are special case, when A and C are identity matrices