Description Usage Arguments Details Value Examples
View source: R/expandFunctions.R
Given a model xObj for which coef(xObj) returns a set of coefficients, plot the coefficients.
The plots make it easier to compare which features are large, which are set to zero, and how features change from run to run in a graphical manner.
If the fitting process is linear (e.g. lm, glmnet, etc.) and the original features are appropriately ordered lags, this will generate an impulse response.
Any coefficients that are exactly zero (for instance, set that way by LASSO) will appear as red X's; non-zero points will be black O's.
1 |
xObj |
Output of a fitting model. |
includeIntercept |
Should the 1st coefficient be plotted? Default is FALSE. |
type |
Graphics type. Default is "h", which results in an impulse-like plot. |
main |
"main" title; default is the relative number of non-zero coefficients, a measure of sparsity. |
... |
Optional additional graphical parameters, for instance to set ylim to a fixed value. |
If includeIntercept==TRUE, the intercept of the model will be plotted as index 0.
Changing the type using type="b"
will result in a parallel coordinate-like plot rather
than an impulse-like plot. It is sometimes easier to
see the differences in coefficients with type="b"
rather than type="h".
Invisibly returns TRUE. Used for its graphic side effects only.
1 2 3 4 5 6 7 8 9 10 11 12 | set.seed(1)
nObs <- 100
X <- distMat(nObs,6)
A <- cbind(c(1,0,-1,rep(0,3))) # Y will only depend on X[,1] and X[,3]
Y <- X %*% A + 0.1*rnorm(nObs)
lassoObj <- easyLASSO(X,Y)
Yhat <- predict(lassoObj,newx=X)
yyHatPlot(Y,Yhat)
coef( lassoObj ) # Sparse coefficients
coefPlot( lassoObj )
coefPlot( lassoObj, includeIntercept=TRUE )
coefPlot( lassoObj, type="b" )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.