1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#' @title Plot the SparseStep path
#'
#' @description Plot the coefficients of the SparseStep path
#'
#' @param x a \code{sparsestep} object
#' @param ... further argument to matplot
#'
#' @export
#' @aliases plot
#'
#' @examples
#' x <- matrix(rnorm(100*20), 100, 20)
#' y <- rnorm(100)
#' fit <- sparsestep(x, y)
#' plot(fit)
#' pth <- path.sparsestep(x, y)
#' plot(pth)
plot.sparsestep <- function(x, ...)
{
index <- log(x$lambda)
coefs <- t(as.matrix(x$beta))
dotlist <- list(...)
type <- ifelse(is.null(dotlist$type), "s", dotlist$type)
lty <- ifelse(is.null(dotlist$lty), 1, dotlist$lty)
matplot(index, coefs, xlab="Log lambda", ylab="Coefficients",
type=type, lty=lty, ...)
}
|