pvarife: Estimate a Panel VAR with Interactive Fixed Effects

View source: R/estimate_pvarife.R

pvarifeR Documentation

Estimate a Panel VAR with Interactive Fixed Effects

Description

Jointly estimates VAR coefficients \beta, latent common factors F, and factor loadings \Lambda for a panel vector autoregression with interactive fixed effects, following the iterative algorithm of Tugan (2021) based on Bai (2009).

Usage

pvarife(y, n_lags, n_factors, n_out = 50L, n_in = 10L, balanced_init = TRUE)

Arguments

y

A numeric array of dimension I \times T \times K (units \times time \times variables). NA values are allowed for unbalanced panels.

n_lags

Positive integer. Lag order \ell.

n_factors

Positive integer. Number of interactive fixed effects r.

n_out

Positive integer. Number of outer iterations (default 50). Corresponds to out_number in the MATLAB replication code.

n_in

Positive integer. Number of inner PCA/EM iterations per outer step (default 10). Corresponds to in_number in the MATLAB code.

balanced_init

Logical. If TRUE (default), the initial beta estimate is obtained from units that have at least 10 fully observed periods in the last window of the sample — matching the approach of the MATLAB Initial_Step_in_Iteration.m for unbalanced real data. Set to FALSE for balanced panels (e.g., Monte Carlo simulations) to skip this selection step and use all units directly.

Details

The model is

y_{i,t} = \sum_{l=1}^{\ell} \Theta_l y_{i,t-l} + F_t \lambda_i + e_{i,t},

where y_{i,t} is a K \times 1 vector of endogenous variables for unit i at time t, F_t is an r \times 1 vector of unobservable common factors, \lambda_i is a unit-specific loading vector, and e_{i,t} is an idiosyncratic error.

The algorithm alternates between:

  1. An inner loop that extracts factors and loadings via PCA (principal components on the residual cross-product matrix) and imputes missing observations (EM step of Bai 2009).

  2. An outer loop that updates \beta via least squares after projecting out the estimated factors (using M_F = I - F(F'F)^{-1}F').

Value

An object of class "pvarife_result", which is a list with:

beta

Coefficient vector of length K + K^2 \ell. The first K elements are equation-specific intercepts; the remaining K^2 \ell elements are VAR lag coefficients stacked as [\Theta_1, \Theta_2, \ldots, \Theta_\ell]' (column-major).

ff

Factor matrix of dimension T \times r (one row per time period; analogous to MATLAB f).

factors_mat

Block-diagonal factor matrix of dimension TK \times Kr, built as I_K \otimes f_t'.

loadings

Matrix of dimension Kr \times I (factor loadings per unit, stacked by variable).

sigma

Reduced-form error covariance matrix (K \times K).

u_c

Array of residuals TK \times 1 \times I (NA at unobserved positions).

y_c, z_c

Stacked outcome/regressor arrays (TK \times 1 \times I and TK \times (K + K^2\ell) \times I).

y_stack, z_stack

Pooled outcome/regressor matrices (complete-case rows only).

i_obs

Integer matrix TK \times I: 1 = observed, 0 = missing.

n_time_i

Integer vector of length I: number of observed time periods per unit (analogous to MATLAB TC).

tnc_i

Integer vector of length I: n\_time\_i \times K (analogous to MATLAB TNC).

n_lags, n_factors, n_vars, n_units, n_time

Dimensions.

References

Tugan, M. (2021). Panel VAR models with interactive fixed effects. Econometrics Journal, 24, 225–246. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/ectj/utaa021")}

Bai, J. (2009). Panel data models with interactive fixed effects. Econometrica, 77(4), 1229–1279.

Examples

sim <- sim_pvarife(n_units = 30, n_time = 20, n_vars = 2,
                   n_lags = 1, n_factors = 1, seed = 1)
fit <- pvarife(sim$y, n_lags = 1, n_factors = 1, n_out = 5, n_in = 3)
print(fit)


pvarife documentation built on June 11, 2026, 5:08 p.m.