When quantile_genlasso() is run with noncross=TRUE, x0=NULL, it intends to enforce the noncrossing constraints at the training points. (When it is run with noncross=TRUE and x0 a matrix with ncol(x) columns, it enforces noncrossing constraints at the specified x0 points.)
This is followed by centering/standardizing/adding an intercept column to x0 so that it is on the same scale as x when used to create constraints in the LP. https://github.com/ryantibs/quantgen/blob/e531952380454c2c1d980db320e16311f04bd6e4/quantgen/R/quantile_genlasso.R#L160-L163 However, if x0=x these operations have already been performed (and trying to redo them will generate erroneous output, or in this case generate an error because x0 already has p+1 columns we are trying to center/scale a matrix with p columns).
Reproducing example
Input:
library(quantgen)
set.seed(1)
n = 50
p = 5
beta = 5 + rnorm(p)
beta0 = 10 + rnorm(1)
X = matrix(rnorm(p*n), ncol=p)
y = X%*%beta + beta0 + rnorm(n)
tau = c(0.05, 0.5, 0.95)
model = quantgen::quantile_lasso(X, y, tau=tau, lambda=0,
intercept=TRUE, standardize=TRUE,
noncross=TRUE,
lp_solver='gurobi')
Output:
Error in scale.default(x0, bx, sx) :
length of 'center' must equal the number of columns of 'x'
Contrast this with the following example, where we explicitly specify noncrossing at the training points, and the standardization occurs as intended.
model = quantgen::quantile_lasso(X, y, tau=tau, lambda=0,
intercept=TRUE, standardize=TRUE,
noncross=TRUE, x0=X,
lp_solver='gurobi')
quantile_genlasso()
is run withnoncross=TRUE, x0=NULL
, it intends to enforce the noncrossing constraints at the training points. (When it is run withnoncross=TRUE
andx0
a matrix withncol(x)
columns, it enforces noncrossing constraints at the specifiedx0
points.)x0=x
is set in https://github.com/ryantibs/quantgen/blob/e531952380454c2c1d980db320e16311f04bd6e4/quantgen/R/quantile_genlasso.R#L157x0
so that it is on the same scale asx
when used to create constraints in the LP. https://github.com/ryantibs/quantgen/blob/e531952380454c2c1d980db320e16311f04bd6e4/quantgen/R/quantile_genlasso.R#L160-L163 However, ifx0=x
these operations have already been performed (and trying to redo them will generate erroneous output, or in this case generate an error because x0 already has p+1 columns we are trying to center/scale a matrix with p columns).Reproducing example
Input:
Output:
Contrast this with the following example, where we explicitly specify noncrossing at the training points, and the standardization occurs as intended.