Fixed Effects models

CategoriesStudy Design , Causal Wizard Concept , Causal Inference

Two way fixed-effects models include fixed effects features for both entity / group and time.

What are Fixed-Effects models?

Fixed-effects models are commonly used in Econometrics to conduct a "quasi-experiment" to obtain a causal effect estimate, or to establish a cause-and-effect relationship.

Usually, several Entities (maybe individuals, but often groups) are observed over a period of time, resulting in multiple measurements of each Entity or group. This is a more generalized form of the popular Difference-in-Differences (DiD) technique, where the number of groups and time periods is relaxed from 2, to any number. Given this experiment design, the data is usually in Panel Data format.

Fixed Effects

Formally, Fixed-effects aim to control for unobserved heterogeneity or time-invariant factors that may affect the dependent (Outcome) variable. That sounds complicated, so let's define it more intuitively: The "effects" in Fixed-Effects means the "effects" of specific entities or specific time periods on the Outcome variable. Since these effects are specific to that entity or moment in time, they are "fixed" for that entity or moment in time. These effects never change. Therefore, "fixed" (unchanging) effects.

For example, imagine you were investigating the effect of a marketing campaign on stores' sales. In this case, the Entities might be individual stores, or stores grouped by being in the same city. Either way, we want to separate the effect of the marketing campaign from the effect of the city or store having inherently, pre-existing, higher or lower sales. Entity fixed effects capture inherent and nonchanging differences between stores or cities. 

If your Entities are individuals, not groups, these are known as Individual Fixed Effects. If you believe that all individuals or groups are all equivalent, you can decide not to include individual or group fixed effects.

Time-based fixed effects are conceptually similar, but aim to capture shocks or changes that were experienced equally by all locations during a given month, such as seasonality of sales or the overall economic environment. 

In fact, any variable could have a fixed effect, but these two are the most common. In fact, this combination has a specific name - a Two Way Fixed Effects model (TWFE).

Importantly, the effects of these entities don't need to be directly observable (recorded in your data). You only need to assume they are constant, and observe the identity of the times and entities involved, and their Outcomes.

These models assume that Treatment occurs immediately and throughout any time period which is indicated as Treated, and immediately ceases to apply if subsequent time periods are marked as not treated. If treatment occurs gradually or has time-varying effects, you may need to restructure your data or use different techniques.

Our final quasi experiment with a TWFE design then looks something like this:

  • Treatment: marketing campaign
  • Outcome: sales
  • Entity fixed effect: Store or City
  • Time fixed effect: Month/Year combination

If you create a Fixed-Effect model in Causal Wizard, you will be asked to specify at least Treatment and Outcome, and optionally Entity and Time fixed-effects.

De-meaning

Fixed effects are calculated uniquely for each Entity or Time period. This means these features are categorical, and must be encoded to present them to the model. Typically, one-hot encoding is used for categorical variable encoding (and is used in Causal Wizard). Since there many be many time periods and many individual samples, this creates an excessive number of categorical indicator features.

To avoid this problem, a technique called de-meaning can be used to add Fixed-effects variables to the model implicitly. The model does not produce a coefficient for the de-meaned variables. De-meaning is applied to Entity and Time fixed-effects in Causal Wizard.

Causal effect

Fixed-effects models will calculate the Average Treatment effect on the Treated (ATT). You might instead wish to obtain the Average Treatment Effect (ATE) - to obtain this effect, use Causal Wizard's Causal Diagram & Potential Outcomes models.

When should I use Fixed-Effects models?

You can use the Fixed Effects models in Causal Wizard when it is appropriate for your data. Typically, if your data is in Panel Data format, which tracks multiple entities or groups over multiple time periods with observations, you might want to use Fixed-Effects models. 

In many cases, you can use both our Fixed-Effects and Causal Diagram + Potential Outcomes models. The latter make available a wider range of models and results, and are more flexible about data format.

Calculating Difference-in-Differences with Fixed-Effects models

You can use the Fixed-Effects models to calculate Difference-in-Differences (DiD), as long as your data is in Panel Data format. This is because DiD is a special case of a Two-Way Fixed-Effects model with two Entity-groups and two Time periods, and a Binary treatment design. See link for details.

Continuous treatment variable and Counterfactuals

If your study design and data have a continuous, numerical treatment, Causal Wizard still provides the opportunity to evaluate counterfactual outcomes

In the Edit Study page, you can define two set points for the Treatment variable. All samples will be evaluated at these levels, in addition to prediction based on actual treatment values.

Covariates

You can also specify additional columns of your data as Covariates, which are simply additional input features provided to the model. Since you are not using a Causal Diagram, you will have to work out the appropriateness of using these variables to eliminate confounding. One tip is to model your problem using both our Fixed-Effects and Causal Diagram + Potential Outcomes methods, which will allow you to automatically identify confounding (backdoor) variables and then select them in the Fixed-Effects model.

Note you can also specify your Time and Entity (group) variables as covariates, if you do not wish them to be de-meaned and you want their coefficients to appear in the results. Ensure to de-select them as explicit Time and Entity variables if you do this.

Implementation engine details

The Fixed-Effects models in Causal Wizard are implemented using Statsmodels' Ordinary Least-Squares (OLS) [linear] Regression, partly because Statsmodels has options to enable robust standard errors. MacKinnon and White's (1985) heteroskedasticity robust standard errors correction (HC1) is enabled for all results. This method corrects based on the degrees of freedom in the model and the number of data samples (observations).

Limitations

There are two common ways for TWFE models to give misleading results:

  1. Reverse causality problem: This is best explained with an example, so follow this link. A remedy is to model your system with an explicit Causal Diagram, if you have a good understanding of the potential interactions of your variables.
  2. Time varying unobserved heterogeneity: Again, follow the link for a detailed explanation. If there are effects which are unobserved and continuously changing, these clearly cannot be accounted for by fixed effects.
Related articles
In categories