Report

Using margins to test for group differences in generalized linear mixed models Sarah Mustillo Purdue University Sarah A. Mustillo, Ph.D Stata Conference Chicago 2011 Introduction Examples Application Conclusion Problem The problem • Linear mixed models (LMM) are a standard model for estimating trajectories of change over time in longitudinal data. • Theory, specification, estimation, and post-estimation evaluation techniques for LMMs are well-developed. • Less so for generalized linear mixed models (GLMM). Sarah A. Mustillo, Ph.D Using Margins to test for group differences in GLMMs Introduction Examples Application Conclusion Problem Testing for group differences • In LMMs, researchers tend to include a group by time interaction term to test for group differences. • Others have suggested that this same procedure can be used in nonlinear models. For example, Rabe-Hesketh and Skrondal (2005) note that the coefficient of the product term can be interpreted as indicating group differences in the rate of change over time in logistic models (pp.115-118) and ordinal models (155-161). • But, interaction terms in nonlinear models are different than interaction terms in linear models. Sarah A. Mustillo, Ph.D Using Margins to test for group differences in GLMMs Introduction Examples Application Conclusion Problem Interpreting interactions in nonlinear models • For example, Ai and Norton (2004) argue that: • The coefficient of the interaction term in a linear model is the same as the first derivative or marginal effect and thus a group by time interaction term in a linear model can be interpreted as group differences in the effect of time on the DV. • In nonlinear models, the first derivative of the interaction term is not the interaction effect. For that, we need the cross-partial derivative of E(y) with respect to group and time. • -inteff- is one way to interpret interactions in logit and probit models, but it’s not a panacea for several reasons. • Only available for logit and probit. • Not available for longitudinal models. • Difficult to interpret and generalize. Sarah A. Mustillo, Ph.D Using Margins to test for group differences in GLMMs Introduction Examples Application Conclusion Problem Longitudinal models • In the longitudinal, mixed model context, the interaction of a grouping variable and a time variable is a test for group differences in slope, but it’s a test on a ratio scale, which isn’t always what we want (or ever, in my case). • The difference in the rate of change (rather than the ratio of change) can be measured by taking the derivative or partial derivative of the conditional expectation of Y with respect to time by group. • When the ratio of change and the rate of change are close, both yield similar results. When they aren’t the same, they provide different results and answer different questions. Sarah A. Mustillo, Ph.D Using Margins to test for group differences in GLMMs Introduction Examples Application Conclusion Motivating example Real example • Using the Established Populations for Epidemiological Studies of the Elderly (EPESE) data, we were exploring the effects of baseline cognitive status on change in physical functioning over time. Physical functioning was measured as a count of instrumental tasks the subject could not perform. We used –xtmepoisson- with a cognitive impairment X time interaction term to test for the group difference in slope. • Based on previous work, we expected baseline cognitive impairment to be associated with greater yearly increases in disability over time. Indeed, descriptive statistics showed an increase of .06 per year in the cognitively intact and .13 in the cognitively impaired. (2) (2) (2) (2) ln( | ζ ,ζ ) β β Tim e β Im pairm ent β Im parim ent*Tim e ζ ζ * Tim e it 1 2 0 1 it 2 i 3 i it 1 2 it i i i i Sarah A. Mustillo, Ph.D Using Margins to test for group differences in GLMMs Introduction Examples Application Conclusion Empirical example Results from –xtmepoissonTable 1. Estimated Mixed Poisson Model of Number of IADL's Regressed on Cognitive Impairment by Time, EPESE Data. Fixed parameters Cognitive impairment Time Cog impairment X Time Intercept B 2.817*** 0.541*** -0.188*** -4.555*** SE (0.161) (0.060) (0.046) (0.144) 0.102 7.562 -0.487 (0.0187) (0.679) (0.115) IRR 16.73 1.72 0.83 Random components Slope variance Intercept variance Covariance Summary Statistics N Chi square Log likelihood 15016 434.050 -8346.699 Note: Standard errors in parentheses * p< .05 **p<.01 *** p<.001 Sarah A. Mustillo, Ph.D Using Margins to test for group differences in GLMMs Introduction Examples Application Conclusion Fake example Fake example - Graphs of generated count variables with gender differences in slope. Graph of gender interaction in simulated Poisson variable with mean = 5. 0 1 2 10 6 4 2 3 0 1 2 time Male Graph of gender interaction in simulated Poisson variable with a mean of 6. 8 Simulated DV, mean=6 7 5 3 0 1 2 4 6 Simulated DV, mean=5 8 9 Graph of gender interaction in simulated Poisson variable with a mean of 4. 0 3 1 2 Female Males Histogram of simulated Poisson variable with a mean of 4. Male Females Female .3 .2 Density .2 0 5 10 Simulated Poisson variable, mean = 4 15 .1 0 0 0 .1 .2 Density .4 .3 .4 Histogram of simulated Poisson variable with a mean of 6. .4 Histogram of simulated Poisson variable with a mean of 5. .6 3 time Time 0 5 10 15 Simulated Poisson variable, mean = 5 Sarah A. Mustillo, Ph.D 20 0 5 10 15 Simulated Poisson variable, mean = 6 Using Margins to test for group differences in GLMMs 20 Introduction Examples Application Conclusion Fake example Fake example - Graphs of generated count variables with gender differences in slope. Graph of gender interaction in simulated Poisson variable with mean = 5. 10 6 1.22 2 4 1.17 1 0 1 2 time Male 3 Graph of gender interaction in simulated Poisson variable with a mean of 6. 8 Simulated DV, mean=6 7 5 1.24 0 2 1.40 1.25 3 4 1.32 Simulated DV, mean=5 6 8 9 Graph of gender interaction in simulated Poisson variable with a mean of 4. 0 1 2 3 0 1 2 time Time Female Ratio Female/Male = 1.32/1.40=.93 Males Females Ratio Female/Male = 1.25/1.24=1.01 Sarah A. Mustillo, Ph.D Male Female Ratio Female/Male = 1.22/1.17=1.03 Using Margins to test for group differences in GLMMs 3 Introduction Examples Application Conclusion Fake example Table 2. Mixed Poisson Regression Models Estimated for Generated Count Variables in EPESE Data (n=16,648). Model 1_______ Model 2______ 4 Mean Outcome= B Model 3_____ 6 5 (S.E) IRR b (S.E) IRR B (S.E) IRR Time .340*** (0.008) 1.406*** .222*** (0.006) 1.250*** .165*** (0.059) 1.180*** Female 1.037*** (0.020) 2.822*** .671*** (0.016) 1.957*** .498*** (0.013) 1.646*** Female*Time -0.065*** (0.009) 0.937*** .005 (0.007) 1.006 .029*** (0.006) 1.030*** Intercept 0.080*** (0.019) 0.741*** (0.014) 1.397*** (0.011) Chi square 13824.89 11435.03 9775.27 Log likelihood 28298.13 31527.75 34031.66 Note: Standard errors in parentheses * p< .05 **p<.01 *** p<.001 Sarah A. Mustillo, Ph.D Using Margins to test for group differences in GLMMs Introduction Examples Application Conclusion Margins Using –margins- to assess the group difference • The interaction term does not test what we want to test here. • We want to calculate the partial derivative of E(Y) with respect to time by group and then test for a significant difference using a Wald test. • Hmmm…does Stata have a command that can do that? Sarah A. Mustillo, Ph.D Using Margins to test for group differences in GLMMs Introduction Examples Application Conclusion Margins Using –margins- to assess the group difference • The interaction term does not test what we want to test here. • We want to calculate the partial derivative of E(Y) with respect to time by group and then test for a significant difference using a Wald test. • Hmmm…does Stata have a command that can do that? • xtmepoisson yvar i.female##c.time || person:time, cov(unstr) var mle • margins , dydx(time) over(female) predict(fixedonly) post • lincom _b[0.female] - _b[1.female] Sarah A. Mustillo, Ph.D Using Margins to test for group differences in GLMMs Introduction Examples Application Conclusion Margins Table 3. Using –margins- following –xtmepoisson- to test for group differences in slope in the fake examples Model 1_______ Model 2______ Model 3_____ 6 4 5 0.93 1.01 1.03 Male 0.693*** (0.018) 0.659***(0.021) 0.687***(0.027) Female 1.359***(0.021) 1.325*** (0.022) 1.329*** (0.025) Difference 0.667***(0.028) 0.665***(0.031) 0.642***(0.037) Mean Outcome= Fem ratio/ Male ratio dy/dt Sarah A. Mustillo, Ph.D Using Margins to test for group differences in GLMMs Introduction Examples Application Conclusion Empirical example Table 4. Using –margins- following –xtmepoisson- to test for group differences in slope in the original example Disability b SE IRR 1.716*** Time .541*** (0.102) 16.727*** Cognitive impairment 2.817*** (2.686) 0.830*** Cog impairment X Time -0.187*** Intercept -4.555*** (0.038) dy/dt No cog impairment 0.015*** (0.002) Cog impairment 0.108*** (0.018) Difference 0.093*** (0.017) Note: Random coefficients omitted, * p<0.05, ** p<0.01, *** p<0.001 Sarah A. Mustillo, Ph.D Using Margins to test for group differences in GLMMs Introduction Examples Application Conclusion Empirical example Table 5. Using –margins- following –xtmepoisson- to test for group differences in slope in the original example with additional covariates and an additional interaction Disability B SE IRR Time .564*** (0.082) 1.758*** Cognitive impairment 2.130*** (1.299) 8.413*** Cog impairment X Time -0.186*** (0.035) 0.830*** Age 0.114*** (0.008) 1.121*** Female -0.032 (0.113) 0.969 Black 0.225* (0.131) 1.253* Income -0.029*** (0.006) 0.972*** Married 0.005 (0.152) 1.005 Married X Time -0.025 (0.040) 0.976 Intercept -12.701*** dy/dt No cog impairment 0.022*** (0.003) Cog impairment 0.163*** (0.024) Difference 0.141*** (0.023) Married 0.019*** (0.003) Unmarried 0.052*** (0.006) Difference 0.033*** (0.005) Sarah A. Mustillo, Ph.D Using Margins to test for group differences in GLMMs Introduction Examples Application Conclusion Summary • In the generalized linear mixed model, the group by time interaction term is measuring differences in the ratio of change, e.g., change on a multiplicative scale. • This isn’t wrong – it just wasn’t what we wanted. • -margins- provides an easy way to test group difference in rate of change over time on an additive scale by allowing us to calculate the partial derivative of the response with respect to time separately by group and then run a significance test between the two. Sarah A. Mustillo, Ph.D Using Margins to test for group differences in GLMMs