plot.flam {flam} | R Documentation |
Plots Function Estimates for Fit of Class "flam"
Description
This function plots the estimated functions from a model estimated using flam
. The user specifies the model of interest (i.e., the tuning parameters) and a plot is made for the estimated association between all non-sparse (or a chosen subset of) features and the outcome.
Usage
## S3 method for class 'flam'
plot(x, index, n.plot = 10, predictor.indicators = NULL,
predictor.labels = NULL, outcome.label = "outcome", ticks = F,
col = "dodgerblue", n.panel.width = NULL, n.panel.height = NULL, ...)
Arguments
x |
an object of class "flam". |
index |
the index for the model of interest to be plotted. Note that |
n.plot |
the number of predictors to be plotted (default of 10). Note that only non-sparse predictors are plotted, however, this argument is ignored if |
predictor.indicators |
a vector indicating which predictor function estimates to plot. The vector should contain the column numbers of |
predictor.labels |
a vector containing the predictor labels of the same length as |
outcome.label |
the name of the outcome used in the y-axis label. By default, the label is "outcome". |
ticks |
a logical ( |
col |
a vector of colors used to plot the function estimates. If |
n.panel.width |
the plots will be plotted with |
n.panel.height |
the plots will be plotted with |
... |
additional arguments to be passed. These are ignored in this function. |
Details
The estimated function fits are drawn by connecting the predictions for all of the observations in x$x
. This may result in fits that appear not to be piecewise consant if only a single observation is observed for a range of x-values.
Author(s)
Ashley Petersen
References
Petersen, A., Witten, D., and Simon, N. (2014). Fused Lasso Additive Model. arXiv preprint arXiv:1409.5391.
See Also
Examples
#See ?'flam-package' for a full example of how to use this package
#generate data
set.seed(1)
data <- sim.data(n = 50, scenario = 1, zerof = 10, noise = 1)
#fit model for a range of tuning parameters
flam.out <- flam(x = data$x, y = data$y, alpha.seq = c(0.8, 0.9, 1))
#we plot the predictor fits for a specific index, e.g. 25
#that is, lambda and alpha of
flam.out$all.lambda[25]; flam.out$all.alpha[25]
plot(flam.out, index = 25)
#the fit only has 5 non-sparse features
#by default, up to 10 non-sparse features with the largest L2 norms are
#plotted, but we can plot a different number of features if desired
plot(flam.out, index = 40, n.plot = 12)
#or we can plot specific predictors of interest
plot(flam.out, index = 40, predictor.indicators = c(1:4, 6, 8, 11, 12))