*! version 1.0.0 27feb2026

Title

xtfifevd -- Fixed Effects Filtered & Vector Decomposition
Estimation for Time-Invariant and Rarely Changing Variables
in Panel Data with Unit Fixed Effects

Syntax

FEVD Estimator (default):

xtfifevd
depvar xvarlist
[if] [in]
, zinvariants(varlist)
[fevd_options]

FEF Estimator:

xtfifevd
depvar xvarlist
[if] [in]
, zinvariants(varlist) fef
[fef_options]

FEF-IV Estimator:

xtfifevd
depvar xvarlist
[if] [in]
, zinvariants(varlist) iv(varlist)
[fefiv_options]

Required
zinvariants(varlist) time-invariant or rarely changing regressors
whose coefficients are of interest

Estimator Selection
fef use Fixed Effects Filtered (FEF) 2-step estimator
(Pesaran & Zhou 2016); default is FEVD 3-stage

iv(varlist) instruments for endogenous z-variables;
implies FEF-IV estimation (Pesaran & Zhou 2016, Eq. 48)

FEVD Options
nointercept2 omit intercept in FEVD stage 2; reproduces
original Plumper-Troeger (2007, Eq. 5); NOT recommended

compare display comparison table of FEVD raw SEs vs
Pesaran-Zhou corrected SEs for time-invariant coefficients

Diagnostics
bwratio report between/within standard deviation ratio
for each z-variable; high ratio suggests FEVD/FEF advantageous

SE/Robust
robust report robust standard errors; labels output as
Robust Std. Err. in estimation table (Pesaran-Zhou SEs are robust
by construction; this option explicitly signals it for papers)

Reporting
level(#) confidence level; default is level(95)

replace allow overwrite of stored estimation results

Data must be declared as panel data using xtset panelvar timevar
before calling xtfifevd.

Description

xtfifevd estimates the coefficients of time-invariant and rarely
changing variables in static panel data models with unit fixed effects.
Standard fixed-effects (FE) estimation removes all time-invariant regressors
via the within transformation, making their coefficients unidentifiable.
xtfifevd solves this problem by implementing three related estimators:

1. FEVD (Fixed Effects Vector Decomposition): The three-stage procedure
proposed by Plumper and Troeger (2007, Political Analysis). Stage 1
estimates a fixed-effects model, Stage 2 decomposes the estimated unit
effects into a part explained by the z-variables and an unexplained residual
h_i, and Stage 3 re-estimates the full model by pooled OLS including h_i.
Critical improvement: This package replaces the inconsistent standard
errors from stage-3 pooled OLS with the correct Pesaran-Zhou (2016)
variance estimator.

2. FEF (Fixed Effects Filtered): The two-step estimator of Pesaran and
Zhou (2016, Econometric Reviews). Step 1 uses FE to estimate time-varying
coefficients beta, Step 2 regresses the time-averaged FE residuals on the
z-variables with an intercept. Pesaran and Zhou (2016, Proposition 3) prove
that FEF and FEVD produce identical point estimates when an intercept is
included in FEVD Stage 2. The only difference is that FEF uses the correct
variance estimator.

3. FEF-IV (Fixed Effects Filtered - Instrumental Variables): An IV
extension of FEF for the case where some or all time-invariant regressors
are correlated with the unobserved individual effects. External instruments
are specified via iv(), and estimation proceeds by 2SLS in the
cross-section regression. For the traditional Hausman-Taylor approach,
see Stata's built-in xthtaylor.

Why not use the original xtfevd? The original xtfevd package
has been removed from SSC. Moreover, Pesaran and Zhou (2016, Section 3.4)
prove that the stage-3 pooled OLS standard errors used by the original FEVD
are inconsistent, leading to severe size distortions. In their Monte
Carlo simulations, the FEVD rejection rate at the nominal 5% level ranges
from 91% to 100%. This package always uses the correct variance
estimator, ensuring valid inference.

Estimators

The Panel Data Model:

y_it = alpha + z_i' gamma + x_it' beta + eta_i + epsilon_it,
i = 1,...,N; t = 1,...,T

where y_it is the dependent variable, x_it is a k x 1 vector of time-varying
regressors, z_i is an m x 1 vector of time-invariant (or rarely changing)
regressors, eta_i are unobserved individual effects, and epsilon_it are
idiosyncratic errors with E(epsilon_it | x_is) = 0 for all t,s.

The FE transformation removes both z_i and eta_i, so gamma cannot be
estimated by xtreg, fe. The estimators in xtfifevd
recover gamma using the structure of the FE residuals.

FEF Estimator (Pesaran & Zhou 2016, Eq. 4-5):

Step 1: Compute the FE estimator beta_hat and the FE residuals
u_hat_it = y_it - beta_hat' x_it
Then average: u_bar_i = T^{-1} sum_t u_hat_it

Step 2: Regress u_bar_i on z_i with an intercept to obtain
gamma_hat_FEF = [sum (z_i - z_bar)(z_i - z_bar)']^{-1}
* sum (z_i - z_bar)(u_bar_i - u_bar)
alpha_hat_FEF = u_bar - gamma_hat' z_bar

FEVD Estimator (Plumper & Troeger 2007, Eq. 4-7):

Stage 1: Same as FEF Step 1.

Stage 2: Regress u_hat_i on z_i (with or without intercept):
u_hat_i = a + z_i' gamma + h_i
h_i = unexplained part of unit effects.

Stage 3: Pooled OLS of y_it on x_it, z_i, and h_i:
y_it = a + x_it' beta_tilde + z_i' gamma_tilde + delta * h_i + eps_it

Proposition 3 (Pesaran & Zhou 2016): When an intercept is included in
Stage 2, gamma_tilde = gamma_hat_FEF (identical point estimates),
beta_tilde = beta_hat_FE, and delta_tilde = 1, exactly.

Proposition 4: Without an intercept in Stage 2 (the original Plumper-Troeger
procedure), gamma_tilde is in general biased and inconsistent.

FEF-IV Estimator (Pesaran & Zhou 2016, Eq. 48):

For endogenous z_i (correlated with eta_i), use instruments r_i:
gamma_hat_FEF-IV = (Q_zr Q_rr^{-1} Q_zr')^{-1} Q_zr Q_rr^{-1} Q_r_ubar
(standard 2SLS of u_bar_i on z_i using instruments r_i)

The instruments r_i must satisfy: (a) correlation with z_i (relevance),
and (b) no correlation with eta_i (exogeneity). The number of instruments
must be at least as large as the number of z-variables.

Options

Required

zinvariants(varlist) specifies the time-invariant or rarely changing
regressors. These are the variables whose coefficients (gamma) cannot be
estimated by standard FE. Time-invariant means z_it = z_i for all t
(e.g., gender, ethnicity, geography). Rarely changing means the within
variation is small relative to the between variation. Use the bwratio
option to assess this.

Estimator Selection

fef requests the FEF (Fixed Effects Filtered) estimator of Pesaran
and Zhou (2016). This is a two-step procedure that produces identical point
estimates to FEVD (when an intercept is in Stage 2) but presents results
in a cleaner two-equation format. The default is FEVD 3-stage.

iv(varlist) specifies external instruments for endogenous
time-invariant regressors and triggers the FEF-IV estimator. The instruments
must be: (i) correlated with the z-variables (first-stage relevance), and
(ii) uncorrelated with the individual effects eta_i (exogeneity). The
number of instruments must be >= the number of z-variables. If the z-variables
are exogenous (uncorrelated with eta_i), the standard FEF estimator (without
instruments) is consistent and more efficient.

FEVD Options

nointercept2 omits the intercept in the FEVD Stage 2 regression. This
reproduces the original procedure of Plumper and Troeger (2007, Eq. 5)
exactly. However, Pesaran and Zhou (2016, Proposition 4) prove that this
version is biased and inconsistent unless
alpha * E[(sum z_i z_i')^{-1} sum z_i] = 0, which fails in general.
A warning is displayed. This option is provided for replication purposes only.

compare displays a side-by-side comparison table for the
time-invariant coefficients showing:

(1) Point estimates (identical for FEVD and FEF)

(2) FEVD raw SEs (from stage-3 pooled OLS — inconsistent)

(3) Pesaran-Zhou corrected SEs (consistent)

(4) t-statistics from both SEs

This option vividly demonstrates the size distortion problem: the FEVD raw
SEs are typically much smaller than the correct ones, leading to
severely inflated t-statistics and false rejection of true null hypotheses.

SE/Robust

robust reports robust standard errors. The Pesaran-Zhou (2016)
variance estimator is robust by construction — it is consistent under
heteroskedasticity and serial correlation of epsilon_it and
heteroskedasticity of eta_i (Pesaran & Zhou 2016, p.7). Specifying
robust labels the coefficient table header as
Robust Std. Err. (the convention that reviewers expect) and sets
e(vce) to "robust" and e(vcetype) to "Robust".
When robust is not specified, the same Pesaran-Zhou standard errors
are still used because they are the only consistent ones; the header
reads PZ Robust Std. Err. and e(vce) = "pesaran-zhou".

Diagnostics

bwratio reports the between- to within-standard deviation ratio for
each z-variable. This ratio measures how "time-invariant" a variable truly
is:

• Ratio = infinity: truly time-invariant (within SD = 0)

• Ratio > 1.7: FEVD/FEF may improve over FE
(at corr(z,u) approx 0.3; see Plumper & Troeger 2007, Figures 2-4)

• Ratio near 1: variable is nearly as variable within
as between panels; FE may be sufficient

• The threshold ratio increases with the correlation
between z and the unobserved effects

Econometric background

Why are time-invariant effects hard to estimate?

In the standard panel model y_it = alpha_i + x_it'beta + epsilon_it, the
within transformation y_it - y_bar_i eliminates both the individual effects
alpha_i and any time-invariant regressors z_i. This is the price of
consistency: by removing the individual effects (which may be correlated with
x_it), FE also removes z_i.

Several approaches exist to recover gamma:

Random Effects (RE): Assumes eta_i uncorrelated with x_it AND z_i.
This is often too restrictive, and the Hausman test frequently rejects
this assumption.

Hausman-Taylor (HT): Uses time-varying exogenous regressors as
instruments for endogenous z_i. Requires correct partitioning of regressors
into exogenous/endogenous groups and assumes homoskedastic, serially
uncorrelated errors. See xthtaylor.

FEVD/FEF: Uses the FE residuals to recover gamma. Requires z_i
uncorrelated with eta_i (for FEF) or valid instruments (for FEF-IV).
Allows heteroskedastic and serially correlated errors.

Key identification assumption: For FEF (without IV), z_i must be
uncorrelated with the unobserved individual effects eta_i. If this
assumption is violated, use FEF-IV with instruments, or use
xthtaylor instead.

Variance estimation

The size distortion problem in FEVD:

The original FEVD procedure uses pooled OLS standard errors from Stage 3.
Pesaran and Zhou (2016, Remark 4) show that these standard errors are
inconsistent because they ignore the generated regressor problem: h_i
is estimated, not observed. Even under homoskedastic IID errors, the FEVD
variance differs from the correct variance by the term
(sigma^2/T) Q_zz^{-1} Q_z_xbar (Q_p - Q_xbar_xbar)^{-1} Q_xbar_z Q_zz^{-1}.
This term is always positive semi-definite, meaning the FEVD SEs are
too small, leading to over-rejection of null hypotheses.

Pesaran-Zhou variance estimator (Eq. 17):

Var_hat(gamma_hat) = N^{-1} Q_zz^{-1} [V_zz_hat + Q_zxbar (N * Var_hat(beta_hat)) Q_xbarz] Q_zz^{-1}

where:

Q_zz = (1/N) sum_i (z_i - z_bar)(z_i - z_bar)' (Eq. 8)

Q_zxbar = (1/N) sum_i (z_i - z_bar)(x_bar_i - x_bar)' (Eq. 9)

V_zz_hat = (1/N) sum_i c_hat_i^2 (z_i - z_bar)(z_i - z_bar)' (Eq. 19)

c_hat_i = y_bar_i - y_bar - (x_bar_i - x_bar)' beta_hat
- (z_i - z_bar)' gamma_hat (Eq. 20)

Var_hat(beta_hat) = HC sandwich from FE: (Eq. 18)
(sum x'_i. x_i.)^{-1} (sum x'_i. e_i e'_i x_i.) (sum x'_i. x_i.)^{-1}

This variance estimator is consistent under heteroskedasticity and
serial correlation of epsilon_it, and heteroskedasticity of eta_i. V_zz_hat
captures the variation in c_hat_i (the residual component attributable to
heterogeneous eta_i and epsilon-bar_i), while the Q_zxbar term captures
the estimation uncertainty from Stage 1.

FEF-IV variance estimator (Eq. 51):

Var_hat(gamma_hat_IV) = N^{-1} H_zr [V_rr_hat + Q_rxbar (N * Var_hat(beta_hat)) Q_xbarr] H_zr'

where H_zr = (Q_zr Q_rr^{-1} Q_zr')^{-1} Q_zr Q_rr^{-1}, and V_rr_hat is
the analogue of V_zz_hat using instrument residuals.

Comparison with other estimators

The following table summarizes the assumptions and properties of the
available estimators for time-invariant effects:

Estimator z_i exogenous? Error assumptions Stata command

FE N/A General xtreg, fe
RE Required General xtreg, re
HT Some endo. IID xthtaylor
FEVD/FEF Required Het. + serial corr. xtfifevd
FEF-IV Some endo. Het. + serial corr. xtfifevd, iv()

When to use each:

• Use FEF/FEVD (xtfifevd) when: z_i is exogenous, errors may be
heteroskedastic/serially correlated, and the b/w ratio is high.

• Use FEF-IV (xtfifevd, iv()) when: some z_i are endogenous and
valid instruments are available.

• Use Hausman-Taylor (xthtaylor) when: errors are IID and
time-varying regressors serve as instruments.

• Use RE (xtreg, re) when: the Hausman test does not
reject the hypothesis that eta_i is uncorrelated with all regressors.

Examples

Setup: Load Stata's built-in NLS panel data (National Longitudinal
Survey of Young Women 14-26). This dataset contains time-invariant variables
race and birth_yr which are dropped by standard FE.

. webuse nlswork, clear

. xtset idcode year

. describe ln_wage tenure hours ttl_exp race birth_yr

Example 1: Standard FE — race and birth_yr are dropped

. xtreg ln_wage tenure hours ttl_exp, fe

. * Note: race and birth_yr do not appear — eliminated by FE

Example 2: FEVD recovers time-invariant coefficients

. xtfifevd ln_wage tenure hours ttl_exp, zinv(race birth_yr)

. * gamma for race and birth_yr are now estimated

Example 3: FEF with robust standard errors (recommended for papers)

. xtfifevd ln_wage tenure hours ttl_exp, zinv(race birth_yr) fef robust

. * Table header shows "Robust Std. Err."; e(vce) = "robust"

Example 4: Compare FEVD raw SEs vs Pesaran-Zhou corrected SEs

. xtfifevd ln_wage tenure hours ttl_exp, zinv(race birth_yr) compare

. * The FEVD raw SEs are much smaller (inconsistent) — PZ SEs are correct

Example 5: Between/within variance ratio diagnostic

. xtfifevd ln_wage tenure hours ttl_exp, zinv(race birth_yr) bwratio

. * race: B/W = Inf (truly time-invariant)

. * birth_yr: B/W = Inf (truly time-invariant)

Example 6: Post-estimation — access stored results

. xtfifevd ln_wage tenure hours ttl_exp, zinv(race birth_yr)

. ereturn list

. matrix list e(gamma_fevd)

. matrix list e(V_gamma_pz)

. matrix list e(V_gamma_fevd_raw)

Example 7: Combined options

. xtfifevd ln_wage tenure hours ttl_exp, zinv(race birth_yr) compare bwratio

Example 8: Reproduce original Plumper-Troeger without intercept
(for replication — not recommended)

. xtfifevd ln_wage tenure hours ttl_exp, zinv(race birth_yr) nointercept2

. * Warning: results may be biased (Pesaran & Zhou 2016, Proposition 4)

Example 9: Post-estimation graphs

. xtfifevd ln_wage tenure hours ttl_exp, zinv(race birth_yr)

. xtfifevd_graph

. xtfifevd_graph, secompare

. xtfifevd_graph, combined saving(fevd_results)

. * See xtfifevd_graph for details

Stored results

xtfifevd stores the following in e():

Scalars

e(N) number of observations

e(N_g) number of groups (panels)

e(T) time periods (rounded for unbalanced panels)

e(T_bar) average time periods (exact, for unbalanced panels)

e(k_x) number of time-varying regressors

e(k_z) number of time-invariant regressors

e(k_iv) number of instruments (FEF-IV only)

e(delta) FEVD stage-3 coefficient on h_i; should be 1.0
by Proposition 3 (FEVD only)

e(sigma2_e) estimated variance of idiosyncratic errors
(from FE)

e(sigma2_u) estimated variance of fixed effects
(from FE)

Macros

e(cmd) xtfifevd

e(method) FEVD, FEF, or FEF-IV

e(depvar) name of dependent variable

e(xvars) names of time-varying regressors

e(zinvariants) names of time-invariant regressors

e(instruments) names of instruments (FEF-IV only)

e(vce) robust or pesaran-zhou

e(vcetype) Robust or PZ Robust

e(ivar) panel variable

e(tvar) time variable

Matrices

e(b) combined coefficient vector [beta_FE, gamma, alpha]

e(V) combined variance-covariance matrix with corrected SEs

e(beta_fe) FE estimates of time-varying coefficients (k_x x 1)

e(gamma_fevd) FEVD estimates of gamma (FEVD only)

e(gamma_fef) FEF estimates of gamma (FEF only)

e(gamma_fefiv) FEF-IV estimates of gamma (FEF-IV only)

e(V_gamma_pz) Pesaran-Zhou corrected variance of gamma
(k_z x k_z)

e(V_gamma_fevd_raw) uncorrected FEVD stage-3 variance of gamma
(FEVD only; for comparison)

Functions

e(sample) marks estimation sample

References

Plumper, T. and V.E. Troeger. 2007.
Efficient estimation of time-invariant and rarely changing variables in finite sample panel analyses with unit fixed effects.
Political Analysis 15(2): 124-139.
https://doi.org/10.1093/pan/mpm002

Pesaran, M.H. and Q. Zhou. 2016.
Estimation of time-invariant effects in static panel data models.
Econometric Reviews.
https://doi.org/10.1080/07474938.2016.1222225

Greene, W. 2011.
Fixed effects vector decomposition: A magical solution to the problem of time-invariant variables in fixed effects models?
Political Analysis 19: 135-146.

Breusch, T., M. Ward, H. Nguyen, and T. Kompas. 2011.
On the fixed-effects vector decomposition.
Political Analysis 19: 123-134.

Hausman, J.A. and W. Taylor. 1981.
Panel data and unobservable individual effects.
Econometrica 49: 1377-1398.

Plumper, T. and V.E. Troeger. 2011.
Fixed-effects vector decomposition: Properties, reliability, and instruments.
Political Analysis 19: 147-164.

Amemiya, T. and T.E. MaCurdy. 1986.
Instrumental-variable estimation of an error-components model.
Econometrica 54: 869-880.

Requirements

Stata 15.1 or later.

Author

Dr. Merwan Roudane

merwanroudane920@gmail.com

Independent Researcher

Please cite this package as:

Roudane, M. (2026). XTFIFEVD: Stata module for Fixed Effects Filtered and
Vector Decomposition estimation of time-invariant effects in panel data.