Question about fixed effects, and state-by -time fixed effects I have seen papers at the US level where they include county fixed effects, and state-by-year fixed effects, i.e.:
$y_{c,t}$ = $\beta$$x_{c,t}$ + $\lambda_c$ + $\mu_{s,t}$ + $\eta_{c,t}$
where c indexes county, t time, and s states, opposed to a more typical county and just year fixed effect.  $\lambda_c$ are county fixed effects, $\mu_{s,t}$ are state-year fixed effects, and $\eta_{c,t}$ is the error term.  They referred to this as 'comparing counties within states'. How does this accomplish that goal? so is this estimator of $\beta$ than estimating $dy/dx$ within a state, and then averaging the state effects over each state?
 A: Consider first the simpler regression:
$$
y_c = \beta x_c + \mu_s + \eta_c
$$
In this regression, the idea is to use the variability of $x$ across counties within states to identify $\beta$. Why would you want that? Maybe because other policies are implemented at the state level that might influence both $x$ and $y$. In this case, omitting the state fixed effects $\mu$ would allow one to use both the cross-county and the cross-state variability of $x$, which might cause a bias.
Running this fixed-effect regression is exactly equivalent to centering your $y$ and your $x$ by removing the state average to each county-level measure and run the simple regression of the centered $y$ on the centered $x$. Or, as you put it, running one regression per state, and then average all state-specific estimates.
Now, let's go back to your specification:
$$
y_{ct} = \beta x_{ct} + \lambda_{c} + \mu_{st} + \eta_{ct}
$$
We are not only using the within-state variability in this case. For instance, if $x$ was varying across counties but constant over time, we could not identify $\beta$. The presence of $\lambda_c$ means that we are identifying $\beta$ from the variability of $x$ over time and across counties within states.
This is a very flexible specification because it allows the different states to have arbitrarily different time evolutions in $y$, and counties to have arbitrarily different levels of $y$. For this reason, it is also quite demanding on the data, and you end up throwing away a lot of the variability in $x$, leading to less precise estimators.
Note that differentiating this equation over time leads to:
$$
\Delta y_{ct} = \beta \Delta x_{ct} + \Delta \mu_{st} + \Delta \eta_{ct}
$$
with $\Delta X_t$ defined as $X_t - X_{t-1}$.
In differences, this model is therefore close to the first one: we rely on the within-state cross-county variability of the time difference of $x$.
