ryantibs / quantgen

Tools for generalized quantile modeling
https://ryantibs.github.io/quantgen
14 stars 9 forks source link

Incorrect logic when `noncross=TRUE, x0=NULL`. #20

Closed huisaddison closed 1 year ago

huisaddison commented 1 year ago

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')