Learn R Programming

midasml (version 0.0.6)

panel_sgl: Panel sg-LASSO regression model

Description

Fits panel data regression model, random and fixed effects, under sg-LASSO penalty function. Options include random effects and fixed effects models, cross-validation and information criteria for \(\lambda\) penalty parameter selection.

Usage

panel_sgl(X, Z = NULL, y, index, entity_indices, gamma_w = NULL, l1_factor = NULL, 
  l21_factor = NULL, dummies_index = NULL, full_est = NULL, 
  regress_choice = c("re", "fe"), method_choice = c("ic", "cv", "initial"), 
  nlam = 100, lambdas = NULL, min_frac = NULL, nfolds = 10, 
  lambda_choice = c("min", "1se"), ic_choice = c("bic", "aic", "aicc"),
  num_cores = NULL, verbose = FALSE, thresh = NULL, 
  outer_thresh = NULL, inner_iter = NULL, outer_iter = NULL)

Arguments

X

NT by p data matrix, where n, t and p respectively denote the number of individuals, sample size and the number of regressors.

Z

dummies matrix for random effects or fixed effects panel data model. If left unspecified, it is computed based on regress_choice choice.

y

NT by 1 vector of outcome.

index

p by 1 vector indicating group membership of each covariate.

entity_indices

NT by 1 vector of individual indices.

gamma_w

sg-LASSO mixing parameter. gamma_w = 1 is LASSO and gamma_w = 0 group LASSO.

l1_factor

l21_factor

dummies_index

vector indicating group membership of \(\alpha\) (default - no grouping).

full_est

pre-estimated parameters based on full sample and regress_choice for a sequence of \(\lambda\)'s.

regress_choice

choose between `re` and `fe`. `re` computes random effects regression with sg-LASSO penalty (default). `fe` computes fixed effects regression with sg-LASSO penalty.

method_choice

choose between `initial`, `ic` and `cv`. `initial` pre-computes initial estimates. `ic` comptes solution based on information criteria (BIC, AIC or AICc). `cv` computes solution based on cross-validation (cv).

nlam

number of \(\lambda\)'s to use in the regularization path.

lambdas

user specified sequence of \(\lambda\) values for fitting. We recommend leaving this to NULL and letting function to self-select values.

min_frac

the minimum value of the penalty parameter, as a fraction of the maximum value.

nfolds

number of folds of the cv loop.

lambda_choice

chose between `min` and `1se`. `min` computes solution that minimizes the cv error. `1se` computes solution such that the cv error is within 1 standard error of the minimum `min`.

ic_choice

choose between `bic`, `aic` and `aicc`. `bic` computes solution that minimizes Bayesian information criterion. `aic` computes solution that minimizes Akaike information criterion. `aicc` omputes solution that minimizes Akaike information corrected criterion.

num_cores

number of cores used to compute cv loop.

verbose

flag to print information.

thresh

convergence threshold for change in beta. We recommend leaving this to NULL.

outer_thresh

outer loop convergence threshold. We recommend leaving this to NULL.

inner_iter

the maximum number of inner sg-LASSO loop iterations. We recommend leaving this to NULL.

outer_iter

the maximum number of outer sg-LASSO loop iterations. We recommend leaving this to NULL.

Value

Parameter estimates of panel data regression model under sg-LASSO penalty.

Details

Examples

Run this code
# NOT RUN {
# simulate DGP
set.seed(1)
t <- 10; n = 5; p = 20; size.groups = 4 
index <- ceiling(1:p / size.groups)
X <- matrix(rnorm(n * t * p), ncol = p, nrow = n*t)
beta <- c(5,4,3,2,1)
y <- X[,1:5] %*% beta + 5*rnorm(n*t)
entity_indices <- sort(rep(1:n,times=t-1))
panel_sgl(X = X, Z = NULL, y = y, index = index, 
  entity_indices = entity_indices, gamma_w = 1, 
  regress_choice = "fe", method_choice = "initial", 
  num_cores = 2, verbose = FALSE)
# }

Run the code above in your browser using DataLab