tv_pagfl {PAGFL} | R Documentation |
The time-varying pairwise adaptive group fused lasso (time-varying PAGFL) jointly estimates the latent group structure and group-specific time-varying functional coefficients in a panel data model. The time-varying coefficients are modeled as polynomial B-splines.
tv_pagfl(
formula,
data,
index = NULL,
n_periods = NULL,
lambda,
d = 3,
M = floor(length(y)^(1/7) - log(p)),
min_group_frac = 0.05,
const_coef = NULL,
kappa = 2,
max_iter = 20000,
tol_convergence = 1e-10,
tol_group = 0.001,
rho = 0.07 * log(N * n_periods)/sqrt(N * n_periods),
varrho = 1,
verbose = TRUE,
parallel = TRUE,
...
)
## S3 method for class 'tvpagfl'
summary(object, ...)
## S3 method for class 'tvpagfl'
formula(x, ...)
## S3 method for class 'tvpagfl'
df.residual(object, ...)
## S3 method for class 'tvpagfl'
print(x, ...)
## S3 method for class 'tvpagfl'
coef(object, ...)
## S3 method for class 'tvpagfl'
residuals(object, ...)
## S3 method for class 'tvpagfl'
fitted(object, ...)
formula |
a formula object describing the model to be estimated. |
data |
a |
index |
a character vector holding two strings specifying the variable names that identify the cross-sectional unit and the time period for each observation. The first string denotes the individual unit, while the second string represents the time period. In case of a balanced panel data set that is ordered in the long format, |
n_periods |
the number of observed time periods |
lambda |
the tuning parameter. |
d |
the polynomial degree of the B-splines. Default is 3. |
M |
the number of interior knots of the B-splines. If left unspecified, the default heuristic |
min_group_frac |
the minimum group size as a fraction of the total number of individuals |
const_coef |
a character vector containing the variable names of explanatory variables that are estimated with time-constant coefficients. All of concerning regressors must be named variables in |
kappa |
the a non-negative weight placed on the adaptive penalty weights. Default is 2. |
max_iter |
the maximum number of iterations for the ADMM estimation algorithm. Default is 20,000. |
tol_convergence |
the tolerance limit for the stopping criterion of the iterative ADMM estimation algorithm. Default is |
tol_group |
the tolerance limit for within-group differences. Two individuals are assigned to the same group if the Frobenius norm of their coefficient vector difference is below this threshold. Default is 0.001. |
rho |
the tuning parameter balancing the fitness and penalty terms in the IC that determines the penalty parameter |
varrho |
the non-negative Lagrangian ADMM penalty parameter. For the employed penalized sieve estimation PSE, the |
verbose |
logical. If |
parallel |
logical. If |
... |
ellipsis |
object |
of class |
x |
of class |
Consider the grouped time-varying panel data model
y_{it} = \gamma_i + \beta^\prime_{i} (t/T) x_{it} + \epsilon_{it}, \quad i = 1, \dots, N, \; t = 1, \dots, T,
where y_{it}
is the scalar dependent variable, \gamma_i
is an individual fixed effect, x_{it}
is a p \times 1
vector of explanatory variables, and \epsilon_{it}
is a zero mean error.
The coefficient vector \beta_{i} (t/T)
is subject to the group pattern
\beta_i \left(\frac{t}{T} \right) = \sum_{k = 1}^K \alpha_k \left( \frac{t}{T} \right) \bold{1} \{i \in G_k \},
with \cup_{k = 1}^K G_k = \{1, \dots, N\}
, G_k \cap G_j = \emptyset
and \| \alpha_k \| \neq \| \alpha_j \|
for any k \neq M
.
\beta_i (t/T)
, and \alpha_k (t/T)
are estimated as polynomial B-splines using penalized sieve-technique. Let \bold{B}(v)
denote a M + d +1
vector basis functions, where d
denotes the polynomial degree and M
the number of interior knots.
Then, \beta_{i}(t/T)
and \alpha_{i}(t/T)
are approximated as \beta_{i} (t/T) = \pi_i^\prime \bold{B}(t/T)
and \alpha_{i}(t/T) = \xi_i^\prime \bold{B}(t/T)
, respectively. \pi_i
and \xi_i
are (M + d + 1) \times p
coefficient matrices which weigh the individual basis functions.
The explanatory variables are projected onto the spline basis system, which results in the (M + d + 1)*p \times 1
vector z_{it} = x_{it} \otimes \bold{B}(v)
. Subsequently, the DGP can be reformulated as
y_{it} = \gamma_i + z_{it}^\prime \text{vec}(\pi_{i}) + u_{it},
where u_{it} = \epsilon_{it} + \eta_{it}
and \eta_{it}
contains the sieve approximation error. I refer to Su et al. (2019, sec. 2) for more details on the sieve technique.
Inspired by Su et al. (2019) and Mehrabani (2023), the time-varying PAGFL estimates the functional coefficients and the group structure by minimizing the criterion:
\frac{1}{NT} \sum^N_{i=1} \sum^{T}_{t=1}(\tilde{y}_{it} - \tilde{z}_{it}^\prime \text{vec}(\pi_{i}))^2 + \frac{\lambda}{N} \sum_{1 \leq i} \sum_{i<j \leq N} \dot{w}_{ij} \| \text{vec}( \pi_i - \pi_j) \|,
where \tilde{y}_{it}
is the demeaned dependent variable, and \tilde{z}_{it}
is likewise demeaned to concentrate out the individual fixed effects \gamma_i
. \lambda
is the penalty tuning parameter and \dot{w}_{ij}
denotes adaptive penalty weights which are obtained by a preliminary non-penalized estimation. \| \cdot \|
represents the Frobenius norm.
The solution \hat{\bold{\beta}}
is computed via the iterative alternating direction method of multipliers (ADMM) algorithm proposed in Mehrabani (2023, sec. 5.1), adapted to accommodate the B-spline coefficient functions.
Two individuals are assigned to the same group if \| \text{vec} (\hat{\pi}_i - \hat{\pi}_j) \| \leq \epsilon_{\text{tol}}
, where \epsilon_{\text{tol}}
is given by tol_group
. Subsequently, the number of groups follows as the number of distinct elements in \hat{\bold{\beta}}
. Given an estimated group structure, it is straightforward to obtain post-Lasso estimates using least squares.
We suggest identifying a suitable \lambda
parameter by passing a logarithmically spaced grid of candidate values with a lower limit of 0 and an upper limit that leads to a fully homogeneous panel. A BIC-type information criterion then selects the best fitting \lambda
value.
In case of an unbalanced panel data set, the earliest and latest available observations out of the entire panel are employed as the start and end-points of the interval on which the time-varying coefficients are defined.
An object of class tvpagfl
holding
model |
a |
coefficients |
a |
groups |
a |
residuals |
a vector of residuals of the demeaned model, |
fitted |
a vector of fitted values of the demeaned model, |
args |
a |
IC |
a |
convergence |
a |
call |
the function call. |
An object of class tvpagfl
has print
, summary
, fitted
, residuals
, formula
, df.residual
and coef
S3 methods.
Paul Haimerl
Dhaene, G., & Jochmans, K. (2015). Split-panel jackknife estimation of fixed-effect models. The Review of Economic Studies, 82(3), 991-1030. doi:10.1093/restud/rdv007.
Mehrabani, A. (2023). Estimation and identification of latent group structures in panel data. Journal of Econometrics, 235(2), 1464-1482. doi:10.1016/j.jeconom.2022.12.002.
Su, L., Wang, X., & Jin, S. (2019). Sieve estimation of time-varying panel data models with latent structures. Journal of Business & Economic Statistics, 37(2), 334-349. doi:10.1080/07350015.2017.1340299.
# Simulate a time-varying panel with a trend and a group pattern
set.seed(1)
sim <- sim_tv_DGP(N = 5, n_periods = 20, intercept = TRUE, p = 1)
df <- data.frame(y = c(sim$y))
# Run the time-varying PAGFL with only an intercept
estim <- tv_pagfl(y ~ 1, data = df, n_periods = 20, lambda = 13, max_iter = 100, parallel = FALSE)
summary(estim)