Learn R Programming

miceadds (version 2.2-0)

pca.covridge: Principal Component Analysis with Ridge Regularization

Description

Performs a principal component analysis for a dataset while a ridge parameter is added on the diagonal of the covariance matrix.

Usage

pca.covridge(x, ridge = 1E-10 )

Arguments

x
A numeric matrix
ridge
Ridge regularization parameter for the covariance matrix

Value

A list with following entries:

See Also

Principal component analysis in stats: stats::princomp

For calculating first eigenvalues of a symmetric matrix see also sirt::eigenvalues.sirt in the sirt package.

Examples

Run this code
## 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 <- 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)

Run the code above in your browser using DataLab