diff options
| author | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2016-02-10 15:27:35 -0500 |
|---|---|---|
| committer | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2016-02-10 15:27:35 -0500 |
| commit | 904e559845f48f38c7eb928d65876e3a064a17c7 (patch) | |
| tree | 1d4153ad46cfe94bda2bd5dc3105acf67b2dc994 /R/postprocess.R | |
| parent | redefine gamma to correspond to theory (diff) | |
| download | sparsestep-904e559845f48f38c7eb928d65876e3a064a17c7.tar.gz sparsestep-904e559845f48f38c7eb928d65876e3a064a17c7.zip | |
add documentation, unify implementations of path and fit
Diffstat (limited to 'R/postprocess.R')
| -rw-r--r-- | R/postprocess.R | 21 |
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) +} |
