tv_pagfl {PAGFL}R Documentation

Time-varying Pairwise Adaptive Group Fused Lasso

Description

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.

Usage

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, ...)

Arguments

formula

a formula object describing the model to be estimated.

data

a data.frame or matrix holding a panel data set. If no index variables are provided, the panel must be balanced and ordered in the long format \bold{Y}=(Y_1^\prime, \dots, Y_N^\prime)^\prime, Y_i = (Y_{i1}, \dots, Y_{iT})^\prime with Y_{it} = (y_{it}, x_{it}^\prime)^\prime. Conversely, if data is not ordered or not balanced, data must include two index variables, declaring the cross-sectional unit i and the time period t for each observation.

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, index can be left empty if the the number of time periods n_periods is supplied. Default is Null.

n_periods

the number of observed time periods T. If an index character vector is passed, this argument can be left empty. Default is Null.

lambda

the tuning parameter. \lambda governs the strength of the penalty term. Either a single \lambda or a vector of candidate values can be passed. If a vector is supplied, a BIC-type IC automatically selects the best fitting parameter value.

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 M = \text{floor}((NT)^{\frac{1}{7}} - \log(p)) is used. Note that M does not include the boundary knots.

min_group_frac

the minimum group size as a fraction of the total number of individuals N. In case a group falls short of this threshold, a hierarchical classifier allocates its members to the remaining groups. Default is 0.05.

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 data.

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 1 * 10^{-10}.

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 \lambda. If left unspecified, the heuristic \rho = 0.07 \frac{\log(NT)}{\sqrt{NT}} of Mehrabani (2023, sec. 6) is used. We recommend the default.

varrho

the non-negative Lagrangian ADMM penalty parameter. For the employed penalized sieve estimation PSE, the \varrho value is trivial. We recommend the default 1.

verbose

logical. If TRUE, helpful warning messages are shown. Default is TRUE.

parallel

logical. If TRUE, certain operations are parallelized across multiple cores.

...

ellipsis

object

of class tvpagfl.

x

of class tvpagfl.

Details

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.

Value

An object of class tvpagfl holding

model

a data.frame containing the dependent and explanatory variables as well as individual and time indices,

coefficients

a list holding (i) a T \times p^{(1)} \times \hat{K} array of the post-Lasso group-specific functional coefficients and (ii) a K \times p^{(2)} matrix of time-constant post-Lasso estimates. Let p^{(1)} denote the number of time-varying coefficients and p^{(2)} the number of time constant parameters,

groups

a list containing (i) the total number of groups \hat{K} and (ii) a vector of estimated group memberships (\hat{g}_1, \dots, \hat{g}_N), where \hat{g}_i = k if i is assigned to group k,

residuals

a vector of residuals of the demeaned model,

fitted

a vector of fitted values of the demeaned model,

args

a list of additional arguments,

IC

a list containing (i) the value of the IC, (ii) the employed tuning parameter \lambda, and (iii) the mean squared error,

convergence

a list containing (i) a logical variable if convergence was achieved and (ii) the number of executed ADMM algorithm iterations,

call

the function call.

An object of class tvpagfl has print, summary, fitted, residuals, formula, df.residual and coef S3 methods.

Author(s)

Paul Haimerl

References

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.

Examples

# 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)


[Package PAGFL version 1.1.0 Index]