[R-sig-ME] Two Questions re: Piecewise mixed effects models

Lofgren, Eric elofgren at email.unc.edu
Sun Sep 30 11:08:36 CEST 2012


I'm relatively new to mixed effects models, and have two fairly basic questions (I think) about a project I'm working on.

Essentially, I'm working on a poisson regression problem where we're trying to estimate the impact of a change in a policy on the rate of an event X. There are N sites where this change has taken place, and we also happen to know another characteristic of each site Z. It's been suggested that I look a a piecewise mixed effects model (which I've also seen referred to as an interrupted time series or "broken stick" model).

I've got two questions about this type of model:

1. As I understand it, you should have two time variables, a "Time Before" and a "Time After" variable, each of which equals 0 right at the point of the policy change. My question is what these variables should look like, specifically what they should look like after they reach zero. For example, with a simple series of 5 points and the policy change in the middle, should it look like this:

Time Before: 2, 1, 0, NA, NA
Time After: NA, NA, 0, 1, 2

or this?

Time Before: 2, 1, 0, -1, -2
TIme After: -2, -1, 0, 1, 2

Or something else entirely?

2. In terms of using something like glmer() to fit the model itself, I'm a little confused about the syntax (I normally use SAS, but am trying to get better at using R). Following some advice I've seen, I should be using something like this:

model <- glmer( rate ~ policy + time.before + time.after + (1+ time.before + time.after + Z |Site) + offset(log(people)), data=data, family="poisson")

First, is this correct? Second, what's accomplished by having the time variables in both the fixed and random effects sections - what does that produce? A fixed slope and random intercept? Something else?

Thanks,

Eric


More information about the R-sig-mixed-models mailing list