View source: R/rlassoEffects.R
rlassoEffects | R Documentation |
Estimation and inference of (low-dimensional) target coefficients in a high-dimensional linear model.
rlassoEffects(x, ...)
## Default S3 method:
rlassoEffects(
x,
y,
index = c(1:ncol(x)),
method = "partialling out",
I3 = NULL,
post = TRUE,
...
)
## S3 method for class 'formula'
rlassoEffects(
formula,
data,
I,
method = "partialling out",
included = NULL,
post = TRUE,
...
)
rlassoEffect(x, y, d, method = "double selection", I3 = NULL, post = TRUE, ...)
x |
matrix of regressor variables serving as controls and potential
treatments. For |
... |
parameters passed to the |
y |
outcome variable (vector or matrix) |
index |
vector of integers, logicals or variables names indicating the position (column) of
variables (integer case), logical vector of length of the variables (TRUE or FALSE) or the variable names of |
method |
method for inference, either 'partialling out' (default) or 'double selection'. |
I3 |
For the 'double selection'-method the logical vector |
post |
logical, if post Lasso is conducted with default |
formula |
An element of class |
data |
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which the function is called. |
I |
An one-sided formula specifying the variables for which inference is conducted. |
included |
One-sided formula of variables which should be included in any case (only for method="double selection"). |
d |
variable for which inference is conducted (treatment variable) |
The functions estimates (low-dimensional) target coefficients in a high-dimensional linear model.
An application is e.g. estimation of a treatment effect \alpha_0
in a
setting of high-dimensional controls. The user can choose between the so-called post-double-selection method and partialling-out.
The idea of the double selection method is to select variables by Lasso regression of
the outcome variable on the control variables and the treatment variable on
the control variables. The final estimation is done by a regression of the
outcome on the treatment effect and the union of the selected variables in
the first two steps. In partialling-out first the effect of the regressors on the outcome and the treatment variable is taken out by Lasso and then a regression of the residuals is conducted. The resulting estimator for \alpha_0
is normal
distributed which allows inference on the treatment effect. It presents a wrap function for rlassoEffect
which does inference for a single variable.
The function returns an object of class rlassoEffects
with the following entries:
coefficients |
vector with estimated values of the coefficients for each selected variable |
se |
standard error (vector) |
t |
t-statistic |
pval |
p-value |
samplesize |
sample size of the data set |
index |
index of the variables for which inference is performed |
A. Belloni, V. Chernozhukov, C. Hansen (2014). Inference on treatment effects after selection among high-dimensional controls. The Review of Economic Studies 81(2), 608-650.
library(hdm); library(ggplot2)
set.seed(1)
n = 100 #sample size
p = 100 # number of variables
s = 3 # number of non-zero variables
X = matrix(rnorm(n*p), ncol=p)
colnames(X) <- paste("X", 1:p, sep="")
beta = c(rep(3,s), rep(0,p-s))
y = 1 + X%*%beta + rnorm(n)
data = data.frame(cbind(y,X))
colnames(data)[1] <- "y"
fm = paste("y ~", paste(colnames(X), collapse="+"))
fm = as.formula(fm)
lasso.effect = rlassoEffects(X, y, index=c(1,2,3,50))
lasso.effect = rlassoEffects(fm, I = ~ X1 + X2 + X3 + X50, data=data)
print(lasso.effect)
summary(lasso.effect)
confint(lasso.effect)
plot(lasso.effect)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.