Enhanced Output for Principal and Sparse Principal Components
princmp(
formula,
data = environment(formula),
method = c("regular", "sparse"),
k = min(5, p),
kapprox = min(5, k),
cor = TRUE,
offset = 0.8,
col = 1,
adj = 0,
scoef = TRUE,
orig = TRUE,
pl = TRUE,
ylim = NULL,
add = FALSE,
sw = FALSE,
nvmax = 5
)
a k-column matrix with principal component scores, with NA
s when the input data had an NA
. If k=1
the result is a vector.
a formula with no left hand side, or a numeric matrix
a data frame or table. By default variables come from the calling environment.
specifies whether to use regular or sparse principal components are computed
the number of components to plot, display, and return
the number of components to approximate with stepwise regression when sw=TRUE
set to FALSE
to compute PCs on the original data scale, which is useful if all variables have the same units of measurement
controls positioning of text labels for cumulative fraction of variance explained
color of plotted text
angle for plotting text
set to FALSE
to not print coefficients (loadings) of standardized variables
set to FALSE
to not show coefficients on the original scale
set to FALSE
to not make the scree plot
y-axis plotting limits, a 2-vector
set to TRUE
to add to an existing plot
set to TRUE
to run stepwise regression PC prediction/approximation
maximum number of predictors to allow in stepwise regression PC approximations
Frank Harrell
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.