princmp | R Documentation |
Enhanced Output for Principal and Sparse Principal Components
princmp(
formula,
data = environment(formula),
method = c("regular", "sparse"),
k = min(5, p - 1),
kapprox = min(5, k),
cor = TRUE,
sw = FALSE,
nvmax = 5
)
formula |
a formula with no left hand side, or a numeric matrix |
data |
a data frame or table. By default variables come from the calling environment. |
method |
specifies whether to use regular or sparse principal components are computed |
k |
the number of components to plot, display, and return |
kapprox |
the number of components to approximate with stepwise regression when |
cor |
set to |
sw |
set to |
nvmax |
maximum number of predictors to allow in stepwise regression PC approximations |
Expands any categorical predictors into indicator variables, and calls princomp
(if method='regular'
(the default)) or sPCAgrid
in the pcaPP
package (method='sparse'
) to compute lasso-penalized sparse principal components. By default all variables are first scaled by their standard deviation after observations with any NA
s on any variables in formula
are removed. Loadings of standardized variables, and if orig=TRUE
loadings on the original data scale are printed. If pl=TRUE
a scree plot is drawn with text added to indicate cumulative proportions of variance explained. If sw=TRUE
, the leaps
package regsubsets
function is used to approximate the PCs using forward stepwise regression with the original variables as individual predictors.
A print
method prints the results and a plot
method plots the scree plot of variance explained.
a list of class princmp
with elements scores
, a k-column matrix with principal component scores, with NA
s when the input data had an NA
, and other components useful for printing and plotting. If k=1
scores
is a vector. Other components include vars
(vector of variances explained), method
, k
.
Frank Harrell
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.