aboutsummaryrefslogtreecommitdiff
path: root/R/plot.sparsestep.R
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2016-02-10 15:27:35 -0500
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2016-02-10 15:27:35 -0500
commit904e559845f48f38c7eb928d65876e3a064a17c7 (patch)
tree1d4153ad46cfe94bda2bd5dc3105acf67b2dc994 /R/plot.sparsestep.R
parentredefine gamma to correspond to theory (diff)
downloadsparsestep-904e559845f48f38c7eb928d65876e3a064a17c7.tar.gz
sparsestep-904e559845f48f38c7eb928d65876e3a064a17c7.zip
add documentation, unify implementations of path and fit
Diffstat (limited to 'R/plot.sparsestep.R')
-rw-r--r--R/plot.sparsestep.R30
1 files changed, 30 insertions, 0 deletions
diff --git a/R/plot.sparsestep.R b/R/plot.sparsestep.R
new file mode 100644
index 0000000..87ab661
--- /dev/null
+++ b/R/plot.sparsestep.R
@@ -0,0 +1,30 @@
+#' @title Plot the SparseStep path
+#'
+#' @description Plot the coefficients of the SparseStep path
+#'
+#' @param obj a \code{sparsestep} object
+#' @param type the plot type, default: "s".
+#' @param lty line type, default: 1
+#' @param ... further argument to matplot
+#'
+#' @author
+#' Gertjan van den Burg (author and maintainer).
+#'
+#' @export
+#' @aliases plot
+#'
+#' @examples
+#' data(diabetes)
+#' attach(diabetes)
+#' fit <- sparsestep(x, y)
+#' plot(fit)
+#' pth <- sparsestep.path(x, y)
+#' plot(pth)
+plot.sparsestep <- function(obj, type="s", lty=1, ...)
+{
+ index <- log(obj$lambda)
+ coefs <- t(as.matrix(obj$beta))
+
+ matplot(index, coefs, xlab="Log lambda", ylab="Coefficients",
+ type=type, lty=lty, ...)
+}