aboutsummaryrefslogtreecommitdiff
path: root/R/postprocess.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/postprocess.R')
-rw-r--r--R/postprocess.R21
1 files changed, 21 insertions, 0 deletions
diff --git a/R/postprocess.R b/R/postprocess.R
new file mode 100644
index 0000000..f43bb05
--- /dev/null
+++ b/R/postprocess.R
@@ -0,0 +1,21 @@
+postprocess <- function(betas, a0, x, normx, nvars, nlambdas) {
+ betas <- scale(betas, FALSE, normx)
+
+ # add names
+ vnames <- colnames(x)
+ if (is.null(vnames)) { vnames <- paste("V", seq(nvars), sep="") }
+ stepnames <- paste("s", seq(nlambdas)-1, sep="")
+ colnames(betas) <- vnames
+ rownames(betas) <- stepnames
+
+ a0 <- t(as.matrix(rep(a0, nlambdas)))
+ colnames(a0) <- stepnames
+ rownames(a0) <- "Intercept"
+
+ # Make it a sparse matrix
+ beta <- drop0(Matrix(as.matrix(t(betas))))
+
+ out <- list(beta = beta, a0 = a0)
+
+ return(out)
+}