Learn R Programming

psvd (version 1.0-0)

calcSVD: Perform singular values decomposition

Description

Given a data matrix, the function allows to perform a singular decomposition using a power method and relationship between SVD factors and the eigendecomposition factors.

Usage

calcSVD(X, r, eta, q, itmax, err, mySeed)

Value

This function returns a data frame containing 4 components

d

Singular values.

u

Matrix with the right eigenvectors.

v

Matrix with the right eigenvectors.

iter

The number of iterations used in the eigendecomposition.

Arguments

X

Data matrix of size (m,n), m >= n.

r

Rank r approximation, default: r=2.

eta

Power method tuning parameter, default: eta=10.

q

Power method tuning parameter, default: q=2.

itmax

Maximum number of iteration in the power method, default: itmax=200.

err

Tolerance level in the power method, default: err=1e-8.

mySeed

An integer allowing to reproduce results from two different runs, default: mySeed=50.

Details

X is usually a data matrix.

Examples

Run this code
data(iris)
X <- as.matrix(iris[,1:4])
rownames(X) <- iris[,5]
res <- calcSVD(X, r=3)
res$d
res$v
res$iter

Run the code above in your browser using DataLab