Description Usage Arguments Details Value References Examples
View source: R/rlassoEffects.R
Estimation and inference of (low-dimensional) target coefficients in a high-dimensional linear model.
1 2 3 4 5 6 7 8 9 10 11 12 | 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 α_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 α_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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | library(hdm); library(ggplot2)
set.seed(1)
n = 100 #sample size
p = 100 # number of variables
s = 3 # nubmer 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)
|
Warning messages:
1: In grep(cn[I.c], colnames(X)) :
argument 'pattern' has length > 1 and only the first element will be used
2: In grep(cn[I.c], colnames(X)) :
argument 'pattern' has length > 1 and only the first element will be used
Call:
rlassoEffects.formula(formula = fm, data = data, I = ~X1 + X2 +
X3 + X50)
Coefficients:
X1 X10 X11 X12 X13 X14 X15 X16
2.94448 -0.03038 0.10862 -0.01007 0.02001 0.09558 -0.01426 -0.10897
X17 X18 X19 X100
-0.04645 -0.06300 -0.10824 0.03385
[1] "Estimates and significance testing of the effect of target variables"
Estimate. Std. Error t value Pr(>|t|)
X1 2.94448 0.08815 33.404 <2e-16 ***
X10 -0.03038 0.07485 -0.406 0.685
X11 0.10862 0.07595 1.430 0.153
X12 -0.01007 0.08012 -0.126 0.900
X13 0.02001 0.07325 0.273 0.785
X14 0.09558 0.09106 1.050 0.294
X15 -0.01426 0.07608 -0.187 0.851
X16 -0.10897 0.07383 -1.476 0.140
X17 -0.04645 0.07942 -0.585 0.559
X18 -0.06300 0.06676 -0.944 0.345
X19 -0.10824 0.07372 -1.468 0.142
X100 0.03385 0.08973 0.377 0.706
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
2.5 % 97.5 %
X1 2.77171308 3.11724213
X10 -0.17709146 0.11632283
X11 -0.04024408 0.25748432
X12 -0.16709410 0.14695616
X13 -0.12356150 0.16358294
X14 -0.08288835 0.27404185
X15 -0.16338572 0.13485904
X16 -0.25367299 0.03574284
X17 -0.20209814 0.10920353
X18 -0.19384187 0.06784675
X19 -0.25273372 0.03624496
X100 -0.14201026 0.20971450
Warning: Ignoring unknown aesthetics: width, h
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.