Description Usage Arguments Value Source Examples
rlassoLoad
performs Lasso estimation under heteroscedastic and autocorrelated non-Gaussian disturbances
with predefined penalty loadings.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
x |
Regressors (vector, matrix or object can be coerced to matrix). |
y |
Dependent variable (vector, matrix or object can be coerced to matrix). |
load |
Penalty loadings, vector of length p (no. of regressors). |
bns |
Block length with default bns=10. |
lns |
Number of blocks with default lns = floor(T/bns). |
nboot |
Number of bootstrap iterations with default nboot=5000. |
post |
Logical. If TRUE (default), post-Lasso estimation is conducted, i.e. a refit of the model with the selected variables. |
intercept |
Logical. If TRUE, intercept is included which is not penalized. |
model |
Logical. If TRUE (default), model matrix is returned. |
X.dependent.lambda |
Logical, TRUE, if the penalization parameter depends on the design of the matrix x. FALSE (default), if independent of the design matrix. |
c |
Constant for the penalty default is 2. |
gamma |
Constant for the penalty default gamma=0.1/log(T) with T=data length. |
numIter |
Number of iterations for the algorithm for the estimation of the variance and data-driven penalty. |
tol |
Constant tolerance for improvement of the estimated variances. |
threshold |
Constant applied to the final estimated lasso coefficients. Absolute values below the threshold are set to zero. |
... |
further parameters |
rlassoLoad returns an object of class "rlasso". An object of class "rlasso" is a list containing at least the following components:
coefficients |
Parameter estimates. |
beta |
Parameter estimates (named vector of coefficients without intercept). |
intercept |
Value of the intercept. |
index |
Index of selected variables (logical vector). |
lambda |
Data-driven penalty term for each variable, product of lambda0 (the penalization parameter) and the loadings. |
lambda0 |
Penalty term. |
loadings |
Penalty loadings, vector of lenght p (no. of regressors). |
residuals |
Residuals, response minus fitted values. |
sigma |
Root of the variance of the residuals. |
iter |
Number of iterations. |
call |
Function call. |
options |
Options. |
model |
Model matrix (if model = TRUE in function call). |
Victor Chernozhukov, Chris Hansen, Martin Spindler (2016). hdm: High-Dimensional Metrics, R Journal, 8(2), 185-199. URL https://journal.r-project.org/archive/2016/RJ-2016-040/index.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
set.seed(1)
T = 100 #sample size
p = 20 # number of variables
b = 5 # number of variables with non-zero coefficients
beta0 = c(rep(10,b), rep(0,p-b))
rho = 0.1 #AR parameter
Cov = matrix(0,p,p)
for(i in 1:p){
for(j in 1:p){
Cov[i,j] = 0.5^(abs(i-j))
}
}
C <- chol(Cov)
X <- matrix(rnorm(T*p),T,p)%*%C
eps <- arima.sim(list(ar=rho), n = T+100)
eps <- eps[101:(T+100)]
Y = X%*%beta0 + eps
fit1 = rlasso(X, Y, penalty = list(homoscedastic = "none",
lambda.start = 2*0.5*sqrt(T)*qnorm(1-0.1/(2*p))), post=FALSE)
beta = fit1$beta
intercept = fit1$intercept
res = Y - X %*% beta - intercept * rep(1, length(Y))
load = rep(0,p)
for(i in 1:p){
load[i] = sqrt(lrvar(X[,i]*res)*T)
}
reg.lasso.load1 <- rlassoLoad(X,Y,load) #lambda is chosen independent of regressor
#matrix X by default.
bn = 10 # block length
reg.lasso.load2 <- rlassoLoad(X, Y,load, bns=bn, nboot=5000,
X.dependent.lambda = TRUE, c=2.7)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.