# How to include population size in difference-in-differences analysis

I'm trying to estimate the effect of a certain policy intervention on the count of violent incidents in communities which received that intervention, compared to communities which didn't. I'm trying to do this using a Poisson difference-in-differences regression.

My question is how best to include information about differing population sizes in the communities. Would it be appropriate to include population as an offset term, or would it be best to simply convert my dependent variable from a count (number of incidents) to a rate (number of incidents per capita)? I remember hearing somewhere that converting a count outcome to a rate is a no-no because it removes information about the exposure, but I may be misremembering this.

• Welcome to CV. Typically, we don’t transform the count. Instead, we include a population offset. I’m curious, does the population size change much over time? How big are your communities? Oct 5, 2021 at 21:45
• Thanks for the warm welcome! These are big city neighbourhoods with fairly stable populations, in the tens of thousands.
– lex
Oct 12, 2021 at 21:53
• No problem. My answer still applies. Does it answer your question? Oct 12, 2021 at 21:56
• Yes it's perfect and very well written, thanks again
– lex
Oct 12, 2021 at 23:05

You do not need to transform the count outcome directly. Instead, simply include the population offset on the right-hand side. But please be aware that your offset/exposure variable is not your typical covariate. Rather than being estimated as a coefficient, its value is constrained to equal 1.

In R, you'd estimate something like the following:

glm(crime ~ treat*post + offset(log(pop)) + other_covariates, family = "poisson", data = ...)


You must wrap the log of the population size inside of the offset() function for this to work. The product term (i.e., treat*post) should be familiar to you, assuming you're estimating a difference-in-differences equation. It's also worth highlighting that this technique is not specific to difference-in-differences; it can be used in a variety of other settings.

Note how if you move the offset term to the left-hand side of your equation and invoke the properties of logarithms, you end up with the number of incidents divided by the community size. For example, the 'difference' can be rewritten as the following:

\begin{align} \ln(crime) - \ln(pop) = \beta' \mathrm{X} \\ \ln\left( \frac{crime}{pop} \right) = \beta' \mathrm{X} \end{align}

which is actually the quantity you wanted to estimate from the start.

To be clear, nothing is stopping you from calculating the rate explicitly. However, once you divide the incident count by the offset (i.e., pop), it alters the variance of the response. To correct for this, you should actually weight by the offset (e.g., weight = pop) when fitting the model. The R code would look something like the following:

glm(I(crime / pop) ~ treat*post + other_covariates, weights = pop, family = "poisson", data = ...)


I highly recommend the former method.