pca.covridge: Principal Component Analysis with Ridge Regularization

View source: R/pca.covridge.R

pca.covridgeR Documentation

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, wt=NULL )

Arguments

x

A numeric matrix

ridge

Ridge regularization parameter for the covariance matrix

wt

Optional vector of weights

Value

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)

See Also

Principal component analysis in stats: stats::princomp

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

Examples

## 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)

miceadds documentation built on May 29, 2024, 11:05 a.m.