postInference.MHLS {EAinference} | R Documentation |
Post-inference with lasso estimator
Description
Provides confidence intervals for the set of active coefficients of lasso using Metropolis-Hastings sampler.
Usage
postInference.MHLS(X, Y, lbd, weights = rep(1, ncol(X)), tau = rep(1,
ncol(X)), sig2.hat, alpha = 0.05, nChain = 10, method,
niterPerChain = 500, parallel = FALSE, ncores = 2L,
returnSamples = FALSE, ...)
Arguments
X |
predictor matrix. |
Y |
response vector. |
lbd |
penalty term of lasso. By letting this argument be |
weights |
weight vector with length equal to the number of coefficients.
Default is |
tau |
numeric vector. Standard deviation of proposal distribution
for each beta. Adjust the value to get relevant level of acceptance rate.
Default is |
sig2.hat |
variance of error term. |
alpha |
confidence level for confidence interval. |
nChain |
the number of chains. For each chain, different plug-in beta will be generated from its confidence region. |
method |
Type of robust method. Users can choose either |
niterPerChain |
the number of iterations per chain. |
parallel |
logical. If |
ncores |
integer. The number of cores to use for parallelization. |
returnSamples |
logical. If |
... |
auxiliary |
Details
This function provides post-selection inference for the active coefficients selected by lasso.
Uses Metropolis-Hastings sampler with multiple chains to draw from the
distribution under a fixed active set and generates (1-alpha)
confidence interval for each active coefficients.
Set returnSamples = TRUE
to check the Metropolis-Hastings samples.
Check the acceptance rate and adjust tau
accordingly.
We recommend to set nChain >= 10
and niterPerChain >= 500
.
Value
MHsamples |
a list of class MHLS. |
confidenceInterval |
(1-alpha) confidence interval for each active coefficient. |
Examples
set.seed(123)
n <- 6
p <- 10
X <- matrix(rnorm(n*p),n)
Y <- X %*% rep(1,p) + rnorm(n)
sig2 <- 1
lbd <- .37
weights <- rep(1,p)
parallel <- (.Platform$OS.type != "windows")
postInference.MHLS(X = X, Y = Y, lbd = lbd, sig2.hat = 1, alpha = .05,
nChain = 3, niterPerChain = 20, method = "coeff", parallel = parallel)
postInference.MHLS(X = X, Y = Y, lbd = lbd, sig2.hat = 1, alpha = .05,
nChain = 3, niterPerChain = 20, method = "coeff", parallel = parallel, returnSamples = TRUE)
postInference.MHLS(X = X, Y = Y, lbd = lbd, sig2.hat = 1, alpha = .05,
nChain = 3, niterPerChain = 20, method = "mu", parallel = parallel)
postInference.MHLS(X = X, Y = Y, lbd = lbd, sig2.hat = 1, alpha = .05,
nChain = 3, niterPerChain = 20, method = "mu", parallel = parallel, returnSamples = TRUE)