Description Usage Arguments Value Author(s) See Also Examples
Performs a principal component analysis for a dataset while a ridge parameter is added on the diagonal of the covariance matrix.
1 | pca.covridge(x, ridge = 1E-10 )
|
x |
A numeric matrix |
ridge |
Ridge regularization parameter for the covariance matrix |
A list with following entries:
loadings |
Matrix of factor loadings |
scores |
Matrix of principal component scores |
sdev |
Vector of standard deviations of factors (square root of eigenvalues) |
Alexander Robitzsch
Principal component analysis in stats:
stats::princomp
For calculating first eigenvalues of a symmetric matrix see also
sirt::eigenvalues.sirt
in the
sirt package.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ## Not run:
#############################################################################
# EXAMPLE 1: PCA on imputed internet data
#############################################################################
library(mice)
data(data.internet)
dat <- as.matrix( data.internet)
# single imputation in mice
imp <- mice::mice( dat , m=1 , maxit=10 )
# apply PCA
pca.imp <- miceadds::pca.covridge( complete(imp) )
## > pca.imp$sdev
## Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7
## 3.0370905 2.3950176 2.2106816 2.0661971 1.8252900 1.7009921 1.6379599
# compare results with princomp
pca2.imp <- stats::princomp( complete(imp) )
## > pca2.imp
## Call:
## stats::princomp(x = complete(imp))
##
## Standard deviations:
## Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7
## 3.0316816 2.3907523 2.2067445 2.0625173 1.8220392 1.6979627 1.6350428
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.