Sweep in standardization
When running glmsmurf
with a continuous predictor that has a Lasso or Group Lasso penalty, there is an error in the standardization. The default behavior of R is to reduce a matrix with one column to a vector which causes the error in the sweep
function which is used in the standardization. This can only happen when there is a single column corresponding to a feature that needs to be standardized, i.e. it has a Lasso or Group Lasso penalty.
Example:
require(smurf)
data("rent", package = "catdata")
rent$kitchen <- factor(rent$kitchen, labels = c("no", "yes"))
formu <- rentm ~ p(rent, pen ="lasso") + p(kitchen, pen ="lasso")
munich.fit <- glmsmurf(formula = formu, family = gaussian(), data = rent, lambda = 0.008914)
which gives the error
Error in array(STATS, dims[perm]) : 'dims' must be of length 0".
Edited by Tom Reynkens