hdqr {hdqr} | R Documentation |
Solve the linear quantile regression. The solution path is computed
at a grid of values of tuning parameter lambda
.
Description
Solve the linear quantile regression. The solution path is computed
at a grid of values of tuning parameter lambda
.
Usage
hdqr(
x,
y,
tau,
nlambda = 100,
lambda.factor = ifelse(nobs < nvars, 0.01, 1e-04),
lambda = NULL,
lam2 = 0.01,
hval = 0.125,
pf = rep(1, nvars),
pf2 = rep(1, nvars),
exclude,
dfmax = nvars + 1,
pmax = min(dfmax * 1.2, nvars),
standardize = TRUE,
eps = 1e-08,
maxit = 1e+06,
sigma = 0.05,
is_exact = FALSE
)
Arguments
x |
Matrix of predictors, of dimension (nobs * nvars); each row is an observation. |
y |
Response variable. The length is |
tau |
The quantile level |
nlambda |
The number of |
lambda.factor |
The factor for getting the minimal value
in the |
lambda |
A user-supplied |
lam2 |
Regularization parameter |
hval |
The smoothing index for |
pf |
L1 penalty factor of length |
pf2 |
L2 penalty factor of length |
exclude |
Indices of variables to be excluded from the model. Default is none. Equivalent to an infinite penalty factor. |
dfmax |
The maximum number of variables allowed in the model.
Useful for very large |
pmax |
The maximum number of coefficients allowed ever
to be nonzero along the solution path. For example, once
|
standardize |
Logical flag for variable standardization,
prior to fitting the model sequence. The coefficients are
always returned to the original scale. Default is |
eps |
Stopping criterion. |
maxit |
Maximum number of iterates. |
sigma |
Penalty parameter appearing in the quadratic term of the augmented Lagrangian function. Must be positive. |
is_exact |
Exact or approximated solutions. Default is |
Details
Note that the objective function in the penalized quantile regression is
1'\rho_{\tau}(y-X\beta-b_0))/N + \lambda_1\cdot|pf_1\circ\beta|_1 +
0.5*\lambda_2\cdot|\sqrt{pf_2}\circ\beta|^2,
where \rho_{\tau}
the quantile or check loss
and the penalty is a combination of weighted L1 and L2 terms and
\circ
denotes the Hadmamard product.
For faster computation, if the algorithm is not converging or
running slow, consider increasing eps
, increasing
sigma
, decreasing nlambda
, or increasing
lambda.factor
before increasing maxit
.
Value
An object with S3 class hdqr
consisting of
call |
the call that produced this object |
b0 |
intercept sequence of length |
beta |
a |
lambda |
the actual sequence of |
df |
the number of nonzero coefficients for each value
of |
npasses |
the number of iterations for every lambda value |
jerr |
error flag, for warnings and errors, 0 if no error. |
Examples
set.seed(315)
n <- 100
p <- 400
x <- matrix(data = rnorm(n * p, mean = 0, sd = 1), nrow = n, ncol = p)
beta_star <- c(c(2, 1.5, 0.8, 1, 1.75, 0.75, 0.3), rep(0, (p - 7)))
eps <- rnorm(n, mean = 0, sd = 1)
y <- x %*% beta_star + eps
tau <- 0.5
lam2 <- 0.01
fit <- hdqr(x = x, y = y, tau = tau, lam2 = lam2)