penhdfeppml_int
is the internal algorithm called by penhdfeppml
to fit a penalized PPML
regression for a given type of penalty and a given value of the penalty parameter. It takes a vector
with the dependent variable, a regressor matrix and a set of fixed effects (in list form: each element
in the list should be a separate HDFE). The penalty can be either lasso or ridge, and the plugin
method can be enabled via the method
argument.
penhdfeppml_int(
y,
x,
fes,
lambda,
tol = 1e-08,
hdfetol = 1e-04,
glmnettol = 1e-12,
penalty = "lasso",
penweights = NULL,
saveX = TRUE,
mu = NULL,
colcheck = TRUE,
colcheck_x = colcheck,
colcheck_x_fes = colcheck,
init_z = NULL,
post = FALSE,
verbose = FALSE,
phipost = TRUE,
standardize = TRUE,
method = "placeholder",
cluster = NULL,
debug = FALSE,
gamma_val = NULL
)
If method == "lasso"
(the default), an object of class elnet
with the elements
described in glmnet, as well as:
mu
: a 1 x length(y)
matrix with the final values of the conditional mean \(\mu\).
deviance
.
bic
: Bayesian Information Criterion.
phi
: coefficient-specific penalty weights (only if method == "plugin"
.
x_resid
: matrix of demeaned regressors.
z_resid
: vector of demeaned (transformed) dependent variable.
If method == "ridge"
, a list with the following elements:
beta
: a 1 x ncol(x)
matrix with coefficient (beta) estimates.
mu
: a 1 x length(y)
matrix with the final values of the conditional mean \(\mu\).
deviance
.
bic
: Bayesian Information Criterion.
x_resid
: matrix of demeaned regressors.
z_resid
: vector of demeaned (transformed) dependent variable.
Dependent variable (a vector)
Regressor matrix.
List of fixed effects.
Penalty parameter (a number).
Tolerance parameter for convergence of the IRLS algorithm.
Tolerance parameter for the within-transformation step,
passed on to collapse::fhdwithin
.
Tolerance parameter to be passed on to glmnet
.
A string indicating the penalty type. Currently supported: "lasso" and "ridge".
Optional: a vector of coefficient-specific penalties to use in plugin lasso when
method == "plugin"
.
Logical. If TRUE
, it returns the values of x and z after partialling out the
fixed effects.
A vector of initial values for mu that can be passed to the command.
Logical. If TRUE
, performs both checks in colcheck_x
and colcheck_x_fes
.
If the user specifies colcheck_x
and colcheck_x_fes
individually, this option is overwritten.
Logical. If TRUE
, this checks collinearity between the independent variables and drops the
collinear variables.
Logical. If TRUE
, this checks whether the independent variables are perfectly explained
by the fixed effects drops those that are perfectly explained.
Optional: initial values of the transformed dependent variable, to be used in the first iteration of the algorithm.
Logical. If TRUE
, estimates a post-penalty regression with the selected variables.
Logical. If TRUE
, it prints information to the screen while evaluating.
Logical. If TRUE
, the plugin coefficient-specific penalty weights are iteratively
calculated using estimates from a post-penalty regression when method == "plugin"
. Otherwise,
these are calculated using estimates from a penalty regression.
Logical. If TRUE
, x variables are standardized before estimation.
The user can set this equal to "plugin" to perform the plugin algorithm with coefficient-specific penalty weights (see details). Otherwise, a single global penalty is used.
Optional: a vector classifying observations into clusters (to use when calculating SEs).
Logical. If TRUE
, this helps with debugging penalty weights by printing output
of the first iteration to the console and stopping the estimation algorithm.
Numerical value that determines the regularization threshold as defined in Belloni, Chernozhukov, Hansen, and Kozbur (2016). NULL default sets parameter to 0.1/log(n).
More formally, penhdfeppml_int
performs iteratively re-weighted least squares (IRLS) on a
transformed model, as described in Breinlich, Corradi, Rocha, Ruta, Santos Silva and Zylkin (2020).
In each iteration, the function calculates the transformed dependent variable, partials out the fixed
effects (calling collapse::fhdwithin
) and then and then calls glmnet
if the selected
penalty is lasso (the default). If the user selects ridge, the analytical solution is instead
computed directly using fast C++ implementation.
For information on the plugin lasso method, see penhdfeppml_cluster_int.
Breinlich, H., Corradi, V., Rocha, N., Ruta, M., Santos Silva, J.M.C. and T. Zylkin (2021). "Machine Learning in International Trade Research: Evaluating the Impact of Trade Agreements", Policy Research Working Paper; No. 9629. World Bank, Washington, DC.
Correia, S., P. Guimaraes and T. Zylkin (2020). "Fast Poisson estimation with high dimensional fixed effects", STATA Journal, 20, 90-115.
Gaure, S (2013). "OLS with multiple high dimensional category variables", Computational Statistics & Data Analysis, 66, 8-18.
Friedman, J., T. Hastie, and R. Tibshirani (2010). "Regularization paths for generalized linear models via coordinate descent", Journal of Statistical Software, 33, 1-22.
Belloni, A., V. Chernozhukov, C. Hansen and D. Kozbur (2016). "Inference in high dimensional panel models with an application to gun control", Journal of Business & Economic Statistics, 34, 590-605.