# Two step regression using group effects and DAG

Consider the following model

$$y_i = \sigma_{c(i)} + \mathbf x_i^\top\beta + u^y_i$$ $$\sigma_{c} = z_c\lambda + \eta_c$$

where for all $$i$$

$$\mathbb E[u^y_i \lvert x_i] = 0$$

Data is given for a random sample $$\{y_i,\mathbf x_i,z_{c(i)}\}_{i=1}^N$$ leaving $$u^y_i, \sigma_c, \eta_c,\lambda$$ and $$\beta$$ unobserved.

Intuitively the model can be interpreted as a two level model where $$i$$ is an observed worker getting wage $$y_i$$ in city $$c$$ and $$z_c$$ are covariates observed on a city level while $$\eta_c$$ are unobserved city specific factors affecting wage additively through $$\sigma_c$$. The function $$c(i)$$ simply connotes the city where individual $$i$$ works.

Clearly estimation of the first equation can be carried out using city specific dummies which would result in an estimate $$\hat \sigma_c$$ for each city (I have very many observations for each city/group so I guess this is ok). Then in order to estimate $$\lambda$$ the second stage regression

$$\hat \sigma_c = z_c \lambda + \eta_c$$

is performed. Can such an approach be justified (give consistent estimate of $$\lambda$$) when

$$\mathbb E[\eta_c \lvert z_c] = 0$$

but

$$\mathbb E[\eta_c \lvert \mathbf x_i] \not = 0,$$

perhaps by considering the DAG of the model which I think could go something like this

which should be implemented in the following code, which I believe shows that the approach works. But I am not sure how to show it using for example arguments from Pearl authorship on DAG's or any other argument given the assumptions.

library(data.table)
library(lfe)

N <- 100000
C <- 300

# Make index over what cities individual worker are in
city_index <- sample(1:C,N,replace=TRUE)

# Make unobserved city productivity effect eta and observed z
eta <- 6*runif(C)
z <- 2*runif(C)
# Calculate city level effect
a <- 1
c_i <- z[city_index]*a + eta[city_index]

# Simulate worker specific skill x
u_x <- rnorm(N)
x <- u_x + c_i
b <- 2
u_y <- rnorm(N)
# Simulate wages
y <- c_i + x*b + u_y

mydata <- data.table(wage=y,city=city_index,skill=x,city_chr=z[city_index])
model_1 <- felm(wage ~ skill + city_chr,data=mydata)
model_2 <- felm(wage ~ skill - 1|city,data=mydata)
model_1
model_2

city_data <- data.table(getfe(model_2))[,.(idx,effect)]
city_data$city_chr <- z lm(effect ~ city_chr,data=city_data) plot(city_data$effect[city_index],c_i)

• Am I not understanding correctly, or should there not also be an arrow pointing from $\mathbf{x}_i$ to $\eta_c$ (in either direction)? Feb 18, 2020 at 10:01
• Because in that case, unbiased estimation of $\sigma_{c(i)}$ is problematic without information on $\eta_c$. That been said, is it reasonable that worker level covariates (strongly) affect city-level fixed effects? Feb 18, 2020 at 10:09
• I think, the DAG is correctly describing the simulation in the code. The link from $\sigma_{c(i)}$ to $x_i$ is there because in the simulation I do x <- u_x + c_i where c_i is actually $\sigma_{c(i)}$. This is kind of a hack. In reality I should have made a multinomial model where individual choice $Pr(c(i) = c)$ is determined is a function of $\sigma_c = z_c \lambda + \eta_c$ and $\mathbf x_i$... the idea here is that individual workers sort across space in the sense that high skilled choose to go to more productive cities (higher $\sigma_c$).Hence $x_i$ and $\sigma_{c(i)}$ is correlated. Feb 18, 2020 at 15:00
• The assumption is not that worker level covariate affect city level covariates. The assumption is that individuals know city level variables and therefore which individuals end up being treated by which city level effects is subject to self selelction. People choose themselves where to live. So while $\mathbf x_i$ and $\sigma_c$ are unrelated $\mathbf x_i$ and $\sigma_{c(i)} = \sum_c \sigma_c 1[c(i) = c]$ is related. If it does not make sense let me know, I am myself just trying to comprehend how to model it correctly and I am not an expert in DAG drawing. Feb 18, 2020 at 15:05

Regarding Pearl-type causality inference, it would be good to evaluate the literature on collider-bias or endogenous selection bias. Generally, estimation of $$\sigma$$ could be biased and therefore estimation of $$\lambda$$ would not yield you're coefficient of interest.

Because you are controlling for $$X$$, you induce a correlation between your estimate for $$\sigma$$ and $$u_x$$ even though the two are not directly correlated. Collider bias is notoriously unintuitive, but you can evaluate this paper for a nice illustration.

The setting in this paper is one where we are interested in the effect of smoking on neonatal fatality, one could control for the birthweight of the child to address other possible factors affecting neonatal mortality (very reasonable at face value). However, because smoking (RF) might affect birthweight (BWT) as well, a scenario is induced where by conditioning on BWT, a possible negative relationship is created between RF and unboserved U. This might generate a situation where a baby with a relatively low BWT but with a smoking mother would actually have a lower risk than the same baby with a low BWT but a non-smoking mother, because the low BWT is coming from U which has an even higher direct risk ($$b$$) of affecting neonatal mortality. This has been proposed as an explanation for the birthweight paradox.

In your case, by conditioning on $$X$$ you would run the risk of a similar possible relationship between $$\sigma$$ and $$U$$ which would affect the estimate for $$\sigma$$ and hence invalidate inference for $$\lambda$$. Note that collider bias can be (very) small, although there are numerous cases where signs flip as a result.

• Looks nice and might raise some interesting questions for the theory I am using. However just to be clear, in the example you use the collider bias can only occur because of the b-link right? And in the model I have there is no such direct link between $u_x$ and $y$? Feb 20, 2020 at 11:46
• Whether they are or aren't obviously should be evaluated theoretically of course but in case of independence it might not matter. In that case, collider bias won't be an issue in identifying $\sigma$. What will prompt reflection is which effect of $\sigma$ on Y you are interested in: the direct effect or the mediated effect through $X$? Feb 20, 2020 at 11:58