Commit f512936a authored by Tom Reynkens's avatar Tom Reynkens

Fix bug in standardization when a continuous predictor is penalized with a...

Fix bug in standardization when a continuous predictor is penalized with a Lasso or Group Lasso penalty
parent f429e234
Type: Package
Package: smurf
Title: Sparse Multi-Type Regularized Feature Modeling
Version: 0.4.1.9008
Date: 2018-10-25
Version: 0.4.1.9009
Date: 2018-11-21
Authors@R: c(
person("Tom", "Reynkens", email = "tomreynkens@hotmail.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-5516-5107")),
......@@ -41,4 +41,4 @@ ByteCompile: yes
Encoding: UTF-8
LazyData: yes
NeedsCompilation: yes
RoxygenNote: 6.1.0
RoxygenNote: 6.1.1
......@@ -341,7 +341,7 @@
if (is.matrix(X)) {
# Standard matrix type
X[, ind.s.e] <- sweep(sweep(X[, ind.s.e], 2L, X.sds[ind.s.e], "*"),
X[, ind.s.e] <- sweep(sweep(X[, ind.s.e, drop = FALSE], 2L, X.sds[ind.s.e], "*"),
2L, X.means[ind.s.e], "+")
} else {
......@@ -353,20 +353,20 @@
if (ind.start == 1) {
# ind.start is first column
X <- cbind(sweep(sweep(X[, ind.s.e], 2L, X.sds[ind.s.e], "*"),
X <- cbind(sweep(sweep(X[, ind.s.e, drop = FALSE], 2L, X.sds[ind.s.e], "*"),
2L, X.means[ind.s.e], "+"),
X[, -ind.s.e])
} else if (ind.end == ncol(X)) {
# ind.end is last column
X <- cbind(X[, -ind.s.e],
sweep(sweep(X[, ind.s.e], 2L, X.sds[ind.s.e], "*"),
sweep(sweep(X[, ind.s.e, drop = FALSE], 2L, X.sds[ind.s.e], "*"),
2L, X.means[ind.s.e], "+"))
} else {
X <- cbind(X[, 1:(ind.start-1L)],
sweep(sweep(X[, ind.s.e], 2L, X.sds[ind.s.e], "*"),
sweep(sweep(X[, ind.s.e, drop = FALSE], 2L, X.sds[ind.s.e], "*"),
2L, X.means[ind.s.e], "+"),
X[, (ind.end+1L):ncol(X)])
}
......
......@@ -280,7 +280,7 @@
if (is.matrix(X)) {
# Standard matrix type
X[, ind.s.e] <- sweep(sweep(X[, ind.s.e], 2L, X.sds[ind.s.e], "*"),
X[, ind.s.e] <- sweep(sweep(X[, ind.s.e, drop = FALSE], 2L, X.sds[ind.s.e], "*"),
2L, X.means[ind.s.e], "+")
} else {
......@@ -292,20 +292,20 @@
if (ind.start == 1) {
# ind.start is first column
X <- cbind(sweep(sweep(X[, ind.s.e], 2L, X.sds[ind.s.e], "*"),
X <- cbind(sweep(sweep(X[, ind.s.e, drop = FALSE], 2L, X.sds[ind.s.e], "*"),
2L, X.means[ind.s.e], "+"),
X[, -ind.s.e])
} else if (ind.end == ncol(X)) {
# ind.end is last column
X <- cbind(X[, -ind.s.e],
sweep(sweep(X[, ind.s.e], 2L, X.sds[ind.s.e], "*"),
sweep(sweep(X[, ind.s.e, drop = FALSE], 2L, X.sds[ind.s.e], "*"),
2L, X.means[ind.s.e], "+"))
} else {
X <- cbind(X[, 1:(ind.start-1L)],
sweep(sweep(X[, ind.s.e], 2L, X.sds[ind.s.e], "*"),
sweep(sweep(X[, ind.s.e, drop = FALSE], 2L, X.sds[ind.s.e], "*"),
2L, X.means[ind.s.e], "+"),
X[, (ind.end+1L):ncol(X)])
}
......
......@@ -61,7 +61,7 @@
if (is.matrix(X)) {
# Standard matrix type
X[, ind.s.e] <- sweep(sweep(X[, ind.s.e], 2L, X.means[ind.s.e], "-"),
X[, ind.s.e] <- sweep(sweep(X[, ind.s.e, drop = FALSE], 2L, X.means[ind.s.e], "-"),
2L, X.sds[ind.s.e], "/")
} else {
......@@ -73,20 +73,20 @@
if (ind.start == 1) {
# ind.start is first column
X <- cbind(sweep(sweep(X[, ind.s.e], 2L, X.means[ind.s.e], "-"),
X <- cbind(sweep(sweep(X[, ind.s.e, drop = FALSE], 2L, X.means[ind.s.e], "-"),
2L, X.sds[ind.s.e], "/"),
X[, -ind.s.e])
} else if (ind.end == ncol(X)) {
# ind.end is last column
X <- cbind(X[, -ind.s.e],
sweep(sweep(X[, ind.s.e], 2L, X.means[ind.s.e], "-"),
sweep(sweep(X[, ind.s.e, drop = FALSE], 2L, X.means[ind.s.e], "-"),
2L, X.sds[ind.s.e], "/"))
} else {
X <- cbind(X[, 1:(ind.start-1L)],
sweep(sweep(X[, ind.s.e], 2L, X.means[ind.s.e], "-"),
sweep(sweep(X[, ind.s.e, drop = FALSE], 2L, X.means[ind.s.e], "-"),
2L, X.sds[ind.s.e], "/"),
X[, (ind.end+1L):ncol(X)])
}
......
......@@ -8,6 +8,7 @@
\itemize{
\item \code{p}: change order of \code{group} and \code{refcat} arguments.
\item \code{mtpglm}: catch errors when computing the maximum value of lambda (\href{https://gitlab.com/TReynkens/smurf/issues/2}{#2}).
\item Fix bug in standardization when a continuous predictor is penalized with a Lasso or Group Lasso penalty (\href{https://gitlab.com/TReynkens/smurf/issues/4}{#4}).
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment