← 4. Repeated & multilevel data
Fixed Effects Models
Try this analysis →

Fixed Effects Models

Estimates a relationship using only the changes that happen within the same unit over time.

Panel dataWithin-unit changeYear fixed effectsCluster-robust standard errors

481200.40.81.21.6Ad spend ($M) →Sales ($M)One pooled lineFirm AFirm BFirm CChange within firm

Does spending more on advertising increase a firm's sales? If you compare advertising spending and sales across many firms, you may find that firms that spend more on advertising tend to have higher sales. But this result alone is not enough to conclude that advertising spending causes higher sales.

That is because larger firms may both spend more on advertising and have higher sales. Characteristics that differ from firm to firm, such as brand awareness, management style and business structure, can also play a role. So how can you analyze the relationship between advertising spending and sales while accounting for differences between firms?

One way is to observe the same firms over several years. You look at how a firm's sales changed when that same firm increased or decreased its advertising spending. A standard method for this kind of analysis is the fixed effects model.

In panel data, where the same firms or individuals are observed at multiple points in time, a fixed effects model controls for unit-specific characteristics that do not change over the observation period and estimates the relationship between the explanatory variable and the outcome.

In this article we cover fixed effects models from the basic principle through the structure of panel data, a worked calculation, interpreting coefficients and result tables, time fixed effects, and the main assumptions and cautions.

SECTION 1

What is a fixed effects model?

A fixed effects model is a regression method that controls for characteristics that do not change within each unit, in data where the same units are observed at multiple points in time.

For example, suppose we surveyed the sales and advertising spending of 100 firms over 5 years. Firms may differ in industry, brand awareness, management style and so on. These differences may affect not only advertising spending but also sales.

If an ordinary regression does not adequately control for these characteristics, the relationship between advertising spending and sales can be distorted. A fixed effects model captures the characteristics that stay constant for each firm throughout the observation period as that firm's fixed effect.

So rather than just comparing the difference in advertising spending between Firm A and Firm B, it estimates the relationship using how Firm A's sales changed in periods when its advertising spending was higher or lower than usual.

The advantage of this approach is that it removes the influence of a firm's time-invariant characteristics even if they are related to advertising spending. However, it does not automatically control for other factors that change over time.

SECTION 2

What is panel data?

Panel data are data in which the same units are observed repeatedly at multiple points in time.

For example, if we surveyed the advertising spending and sales of 3 firms over 4 years, we could build data like the following.

FirmYearAd spend ($M)Sales ($M)
A20220.45.0
A20230.65.8
A20240.86.4
A20251.07.2
B20221.010.4
B20231.211.0
B20241.010.6
B20251.412.0
C20220.22.8
C20230.43.6
C20240.64.0
C20250.43.4

These data contain two kinds of information at once. One is the difference between firms. Firm B generally has higher advertising spending and sales than Firm C. The other is the change within the same firm over time. Firm A's advertising spending and sales both increased from 2022 to 2025.

One pooled lineWithin each firmABCAd spend →Ad spend →
Differences between firms and changes within firms

Of these, the fixed effects model uses the change over time within the same firm. Panel data can be built not only on firms but on many kinds of units, such as individuals, schools, hospitals, countries and regions.

SECTION 3

How is it different from ordinary regression?

An ordinary pooled OLS regression can estimate the relationship between the explanatory variable and the outcome by pooling all the observations in the panel data together.

For example, when analyzing the advertising spending and sales of 100 firms, it can use both the differences in advertising spending across firms and each firm's changes over time. But this can be a problem if firms have unobserved characteristics such as size or brand awareness.

Just because Firm B spends more on advertising than Firm A and also has higher sales, we cannot attribute the whole sales gap to advertising spending. A fixed effects model eases this problem by controlling for each firm's time-invariant characteristics.

AspectPooled OLSFirm fixed effects model
Variation used in the analysisDifferences between firms and changes within firmsMainly within-firm change
Time-invariant firm characteristicsOmitted unless controlled separatelyControlled by fixed effects
Coefficients of time-invariant variablesMay be estimableCannot be estimated separately alongside firm fixed effects
Main questionDo observations with higher ad spend also have higher sales?Is a change in the same firm's ad spend related to a change in its sales?

Applying a fixed effects model can reduce confounding caused by characteristics that do not change within each firm. But if there are time-varying factors that affect both advertising spending and sales, the estimate can still be biased.

SECTION 4

How is a fixed effects model set up?

A basic model with firm fixed effects can be written as follows.

Yit = β·Xit + αi + εit

Here is what each symbol means.

SymbolMeaning
YitSales of firm i at time t
XitAd spend of firm i at time t
βRegression coefficient between ad spend and sales
αiFixed effect that does not change within each firm
εitError not explained by the model

Suppose, for instance, that brand awareness differs across firms but its level does not change over the 4-year observation period. The firm fixed effects control for this kind of time-invariant characteristic. So the coefficient on advertising spending is estimated from how sales change when advertising spending changes within each firm.

Here αi means that instead of applying one common intercept to all firms, each firm is allowed its own intercept.

SECTION 5

How are fixed effects actually removed?

A standard way to understand fixed effects models is the within transformation.

It subtracts each firm's own mean from that firm's observations. For example, if Firm A's advertising spending over 4 years was $0.4 million, $0.6 million, $0.8 million and $1.0 million, its mean advertising spending is $0.7 million. Subtracting the mean from each year's advertising spending gives the following.

YearAd spendFirm meanDeviation from mean
20220.40.7-0.3
20230.60.7-0.1
20240.80.7+0.1
20251.00.7+0.3
Original values0.420220.620230.820241.02025Mean 0.7Deviation from mean−0.32022−0.12023+0.12024+0.320250
Within transformation

The same transformation can be applied to sales. Because each firm's fixed effect is constant over the observation period, it disappears when the firm's mean is subtracted. In equation form:

Yit − Ȳi = β(Xit − X̄i) + (εit − ε̄i)

In this process the firm fixed effect αi is removed. So the influence on the coefficient of unobserved characteristics that stay constant within each firm can be removed. This is the standard estimation method used in ordinary linear fixed effects models.

SECTION 6

Worked example: advertising spending and sales

Suppose a researcher collected 5 years of data, from 2021 to 2025, on 80 manufacturing firms.

If every firm was observed every year, there are 400 firm-year observations in total. The researcher wants to find out how advertising spending relates to firm sales.

Analysis data

VariableRoleDescription
SalesDependent variableAnnual sales, $M
Ad spendMain explanatory variableAnnual advertising spending, $M
Number of employeesControl variableTime-varying variable representing firm size
Capital investmentControl variableAnnual capital investment, $M
Firm IDUnit identifierDistinguishes firm fixed effects
YearTime identifierControls for common changes by year

The research question is:

"Controlling for characteristics that do not change within each firm and for common changes by year, how is an increase in advertising spending related to an increase in sales?"

Suppose we analyzed this with a model that includes both firm fixed effects and year fixed effects. Besides advertising spending, number of employees and capital investment were included as explanatory variables.

SECTION 7

How do you interpret actual fixed effects results?

These are the results of analyzing the data on the 80 manufacturing firms above.

Fixed effects regression results

VariableCoefficient (B)Standard errorp-value
Ad spend ($M)2.400.65< .001
Employees (per 10)0.240.096.012
Capital investment ($M)0.850.32.008

Includes firm and year fixed effects. Standard errors assume clustering by firm, and the figures shown are rounded.

01234Ad spend$1M2.40Number of employees10 employees0.24Capital investment$1M0.8595% interval
Fixed effects coefficients

The coefficient on advertising spending was 2.40. This means that within the same firm, controlling for number of employees, capital investment and common year effects, periods when advertising spending was $200,000 higher were associated with sales that were on average $480,000 higher.

The coefficient on number of employees was 0.24, so periods with 10 more employees were associated with sales that were on average $240,000 higher. The coefficient on capital investment was 0.85, so periods when capital investment was $200,000 higher had sales that were on average $170,000 higher.

These results show conditional associations that take into account firms' time-invariant characteristics and common changes by year.

They should not be interpreted as a causal effect meaning that increasing advertising spending by $200,000 will necessarily increase sales by $480,000.

For example, if firms raised advertising spending in advance because they expected demand to grow, a positive relationship between advertising spending and sales could be observed.

SECTION 8

Why are year fixed effects (time fixed effects) needed?

Firm fixed effects control for characteristics that do not change within each firm.

But there are also economic conditions that affect all firms in common. For example, a recession, inflation, interest rate changes or an industry-wide rise in demand may occur in a particular year. Such changes can affect both firms' sales and their advertising spending.

2023 common shockFirm AFirm BFirm C20212022202320242025
Common changes by year

So in addition to firm fixed effects, you can add year fixed effects. This is called a two-way fixed effects model.

Yit = β·Xit + αi + λt + εit

Here λt is the time effect common to all units in each year. For example, if demand across all of manufacturing fell in 2023, the year fixed effect can capture that year's common change.

So a two-way fixed effects model can control both for characteristics that do not change within each firm and for year-to-year changes that act on all firms in common. However, time-varying factors whose effects differ by firm, such as business cycles that play out differently by industry, may not be adequately controlled by year fixed effects alone.

SECTION 9

Which variables can't be estimated in a fixed effects model?

An important feature of fixed effects models is that they cannot estimate a separate coefficient for variables whose values do not change over the observation period.

For example, suppose firms' locations did not change during the analysis period. When firm fixed effects are included, the effect of location overlaps completely with the firm fixed effects. So no separate coefficient for location can be estimated.

2022202320242025Home countryUSUSUSUSNot estimableAnnual ad spend$0.4M$0.6M$0.8M$1.0MEstimable
Variables that change and variables that don't
VariableChanges during observation period?In a firm fixed effects model
Annual ad spendChangesCoefficient can be estimated
Annual salesChangesCan be analyzed as the dependent variable
Number of employeesChangesCoefficient can be estimated
Home countryNo changeNo separate coefficient can be estimated
Firm's founding yearNo changeNo separate coefficient can be estimated

This does not mean the variable is unimportant. It means that because the firm fixed effects also absorb characteristics that do not change over time, that variable's individual effect cannot be separated out. However, terms that do actually change over time, such as an interaction between a time-invariant variable and a time-varying variable, can be estimated under suitable conditions.

SECTION 10

How do fixed effects and random effects models differ?

In panel data analysis, fixed effects models are often compared with random effects models.

The key difference between the two lies in what they assume about the relationship between unobserved unit-specific characteristics and the explanatory variables.

AspectFixed Effects ModelsRandom effects model
Unit-specific characteristicsControlled by unit fixed effectsModeled as random unit effects
Correlation between unit effects and explanatory variablesAllowedAssumed uncorrelated in the basic model
Main informationChange within unitsUses both within-unit and between-unit information
Coefficients of time-invariant variablesCannot be estimated separatelyMay be estimable
Main considerationsIs there enough within-unit variation?Is the assumption of no correlation between unit effects and explanatory variables reasonable?

For example, if a firm's brand awareness is related to its advertising spending, the basic assumption of the random effects model may not be appropriate. A fixed effects model can allow this correlation between firms' time-invariant characteristics and advertising spending. But that does not make the fixed effects model better in every situation.

Choose the appropriate method by considering the purpose of the analysis, the data structure, the nature of the explanatory variables, the model assumptions and so on. A standard statistical procedure for comparing the two methods is the Hausman test.

SECTION 11

Why do standard errors matter?

In panel data, values observed repeatedly for the same firm may not be independent of one another.

For example, if an unexpected problem hit a particular firm's sales, its effects might carry over into the next year. When errors within the same firm are related like this, using ordinary OLS standard errors as they are can distort judgments of statistical significance.

So panel data analysis often uses cluster-robust standard errors clustered by firm. These allow for heteroskedasticity and correlation over time in the errors within the same firm. But clustering by firm alone does not solve every problem.

For example, when the errors of several firms are related in the same year, cross-sectional dependence may also need to be considered. And when there are few clusters, the usual cluster-robust standard error approximation can be inaccurate, so a separate small-sample correction or inference method should be considered.

So when reporting fixed effects regression results, it is good to state not only the coefficients but also how the standard errors were computed.

SECTION 12

Cautions with fixed effects models

Fixed effects models can control for unobserved time-invariant characteristics, but they do not remove all bias.

Time-varying confounders

If each firm's brand awareness is constant throughout the observation period, it can be controlled by firm fixed effects. But if brand awareness changes with ad campaigns or market shifts, it can become a time-varying confounder. If these changes affect both advertising spending and sales, the coefficient can be biased.

Reverse causality

An increase in advertising spending may be related to an increase in sales, but it is also possible that firms increased advertising spending because sales went up. A fixed effects model alone does not automatically resolve this kind of reverse causality.

Strict exogeneity assumption

For a causal interpretation of the coefficients in ordinary static fixed effects estimation, the strict exogeneity assumption is important: the explanatory variables must have a suitable conditional independence relationship with the error terms across all of a unit's time points. For example, if an unexpected sales shock this year affects next year's advertising spending decision, that assumption can be violated.

Too little within-unit variation

If a firm's advertising spending is the same throughout the observation period, that firm provides none of the within-unit variation needed to identify the coefficient on advertising spending. So in fixed effects analysis, what matters is not only the number of units but also whether the explanatory variables vary enough within each unit.

Dynamic relationships

When past sales affect current sales and a lag of the dependent variable is included, ordinary fixed effects estimation can suffer from dynamic panel bias. Especially when there are few time points, consider a separate dynamic panel analysis method.

SECTION 13

How do you report fixed effects results?

When reporting fixed effects results, it is good to present the study units and observation period, the explanatory and dependent variables, the fixed effects included, how standard errors were computed, and the coefficients and p-values together.

Using the manufacturing firms' advertising and sales example above, a report might read as follows.

Example report

A panel regression with firm and year fixed effects was conducted to analyze the relationship between advertising spending and sales among manufacturing firms. The sample consisted of 400 firm-year observations for 80 manufacturing firms from 2021 to 2025. The dependent variable was annual sales, and the main explanatory variable was advertising spending. Number of employees and capital investment were included as control variables, and cluster-robust standard errors by firm were used to account for possible correlation of errors within the same firm. Advertising spending showed a statistically significant positive relationship with sales (B = 2.40, SE = 0.65, p < .001). This means that within the same firm, periods when advertising spending was $200,000 higher were associated with sales that were on average $480,000 higher. However, because this analysis uses observational data, it is difficult to conclude that this is the causal effect of increased advertising spending.

In an actual report, you can present not only the number of units and observations but also the type of fixed effects, the standard error method, the variation of the explanatory variables within the sample, model fit statistics and so on.

In fixed effects models in particular, the within R², which shows explanatory power within units, is sometimes reported. However, how R² is calculated can differ by software, so check its definition.

✓Wrap-up

A fixed effects model compares changes over time within the same unit.

A fixed effects model is a regression method that controls for characteristics that do not change within each unit, in panel data where the same firms, individuals, regions and so on are observed at multiple points in time.


This method can remove the influence of characteristics that remain constant over the observation period, such as brand awareness or management style that differ from firm to firm, even when they are related to the explanatory variable. So the coefficients of a fixed effects model are estimated mainly from how the outcome changes when the explanatory variable changes within the same unit.

Including year fixed effects also controls for period-specific changes that act on all units in common. But time-varying confounders and reverse causality are not automatically resolved. So the mere fact that you used a fixed effects model does not prove a causal relationship.

KEY TAKEAWAY

The key to a fixed effects model is not simply comparing different firms, but estimating the relationship between the explanatory variable and the outcome using the changes that occurred within the same firm over time.