Sarah A. Mustillo, Ph.D
Stata Conference Chicago 2011
Introduction
Examples
Application
Conclusion
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
• 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
• 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
• 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
• 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.
ln(
it
| ζ
(2)
,ζ
1 i
(2)
)
2 i
β
0
β
1
Time it
β
2
Impairment i
β
3
Impariment i
*Time it
ζ
(2)
1 i
ζ
(2)
2 i
* Time it
Sarah A. Mustillo, Ph.D
Using Margins to test for group differences in GLMMs
Introduction
Examples
Application
Conclusion
Empirical example
Table 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
Random components
Slope variance
Intercept variance
Covariance
Summary Statistics
N
Chi square
Log likelihood
Note: Standard errors in parentheses
* p< .05 ** p<.01 *** p<.001
Sarah A. Mustillo, Ph.D
B
2.817***
0.541***
-0.188***
-4.555***
0.102
7.562
-0.487
15016
434.050
-8346.699
SE
(0.161)
(0.060)
(0.046)
(0.144)
(0.0187)
(0.679)
(0.115)
IRR
16.73
1.72
0.83
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.
Graph of gender interaction in simulated Poisson variable with a mean of 4.
Graph of gender interaction in simulated Poisson variable with a mean of 6.
0 1
Male time
2
Female
3 0
Histogram of simulated Poisson variable with a mean of 4.
1
Males
Time
2
Females
3
0
Histogram of simulated Poisson variable with a mean of 5.
1
Male time
2
Female
3
Histogram of simulated Poisson variable with a mean of 6.
0 5 10
Simulated Poisson variable, mean = 4
15
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.
Graph of gender interaction in simulated Poisson variable with a mean of 4.
Graph of gender interaction in simulated Poisson variable with a mean of 6.
1.22
1.25
1.32
1.40
1.24
1.17
0 1
Male time
2
Female
3
0 1
Males
Time
2
Females
3
0 1
Male time
2
Female
3
Ratio Female/Male =
1.32/1.40=.93
Ratio Female/Male =
1.25/1.24=1.01
Ratio Female/Male =
1.22/1.17=1.03
Sarah A. Mustillo, Ph.D
Using Margins to test for group differences in GLMMs
Introduction
Examples
Application
Conclusion
Fake example
Table 2. Mixed Poisson Regression Models Estimated for Generated Count Variables in EPESE Data (n=16,648).
Mean Outcome=
Time
Female
Female*Time
Intercept
B
.340
***
Model 1_______
4
(S.E)
(0.008)
IRR
1.406
*** b
.222
***
Model 2______
5
(S.E)
(0.006)
IRR
1.250
***
B
.165
***
1.037
*** (0.020) 2.822
*** .671
*** (0.016) 1.957
*** .498
***
-0.065
*** (0.009) 0.937
*** .005
0.080*** (0.019) 0.741***
(0.007)
(0.014)
1.006
Model 3_____
6
(S.E)
(0.059)
IRR
1.180
***
(0.013) 1.646
***
.029
*** (0.006) 1.030
***
1.397*** (0.011)
Chi square 13824.89
Log likelihood 28298.13
Note: Standard errors in parentheses
* p< .05 ** p<.01 *** p<.001
11435.03
31527.75
9775.27
34031.66
Sarah A. Mustillo, Ph.D
Using Margins to test for group differences in GLMMs
Introduction
Examples
Application
Conclusion
Margins
• 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
• 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
Mean Outcome=
Fem ratio/
Male ratio
Model 1_______
4
0.93
Model 2______
5
1.01
Model 3_____
6
1.03
dy/dt
Male
Female
Difference
0.693*** (0.018)
1.359***(0.021)
0.667***(0.028)
0.659***(0.021)
1.325*** (0.022)
0.665***(0.031)
0.687***(0.027)
1.329*** (0.025)
0.642***(0.037)
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 b
Disability
SE
IRR
1.716***
Time .541*** (0.102)
16.727***
Cognitive impairment 2.817*** (2.686)
0.830***
Cog impairment X Time -0.187*** (0.038)
Intercept dy/dt
-4.555***
No cog impairment
Cog impairment
0.015***
0.108***
(0.002)
(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
Time
Cognitive impairment
B
.564***
2.130***
SE
(0.082)
(1.299)
IRR
1.758***
8.413***
Cog impairment X Time
Age
Female
Black
Income
Married
Married X Time
Intercept
-0.186***
0.114***
-0.032
0.225*
-0.029***
0.005
-0.025
-12.701***
(0.035)
(0.008)
(0.113)
(0.131)
(0.006)
(0.152)
(0.040)
0.830***
1.121***
0.969
1.253*
0.972***
1.005
0.976
dy/dt
No cog impairment
Cog impairment
Difference
Married
Unmarried
Difference
0.022***
0.163***
0.141***
0.019***
0.052***
0.033***
(0.003)
(0.024)
(0.023)
(0.003)
(0.006)
(0.005)
Sarah A. Mustillo, Ph.D
Using Margins to test for group differences in GLMMs
Introduction
Examples
Application
Conclusion
• 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