% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.autotune_lasso.R
\name{plot.autotune_lasso}
\alias{plot.autotune_lasso}
\title{Plots for autotune_lasso objects}
\usage{
\method{plot}{autotune_lasso}(x, max_preds = NULL, cumulative = TRUE, ...)
}
\arguments{
\item{x}{Fitted \code{"autotune_lasso"} object.}

\item{max_preds}{Integer input stating maximum number of predictors to include in the plot. 
Default NULL (then max_preds is calculated internally). Plotting R-squared 
involves running \code{max_preds} many linear models, in order to reduce 
the computation, use it with the value \code{v} when you want to check 
whether the dataset satisfies the sparsity assumption with 
\eqn{\leq} \code{v} many predictors or not.}

\item{cumulative}{Logical input. If TRUE, plots cumulative R-squared; if FALSE, plots 
adjusted R-squared.}

\item{...}{Other graphical parameters to plot}
}
\value{
Invisibly returns a data frame with columns:
\describe{
  \item{\code{n_predictors}}{Number of predictors included in the nested
  linear model.}
  \item{\code{predictor_index}}{Index of the predictor added at each step.}
  \item{\code{has_nonzero_beta}}{Logical value indicating whether the
  predictor added at each step has a non-zero coefficient.}
  \item{\code{r_squared}}{Cumulative R-squared value.}
  \item{\code{adj_r_squared}}{Adjusted R-squared value.}
}
}
\description{
Plots for autotune_lasso objects
}
\examples{

# Fit autotune lasso
set.seed(10)
n = 300
p = 500
s = 10
beta = c(rep(1, s), rep(0, p - s))
x = matrix(rnorm(n * p), ncol = p)
# Maunal sigma allocation
# y = x \%*\% beta + rnorm(n, sd = 1)
# Dynamic sigma allocation with snr specified
snr = 2
y = x \%*\% beta + rnorm(n, sd = sqrt(var(x\%*\%beta)/snr))
fit <- autotune_lasso(x, y)

# Basic diagnostic plot
plot(fit)

# Plot adjusted R-squared for first 15 predictors
plot(fit, max_preds = 15, cumulative = FALSE)


}
\seealso{
\code{\link{autotune_lasso}}
}
