Description Usage Arguments Value Examples

Set the rank of a spectralDecomp object by truncation

1 2 3 | ```
## S4 method for signature 'spectralDecomp'
setDecompRank(decomp,
rank = ncol(decomp@vectors), varianceFraction = 1)
``` |

`decomp` |
object of spectralDecomp class |

`rank` |
of decomposition to bet set by truncating trailing eigen values |

`varianceFraction` |
fraction of variance to retain after truncating trailing eigen values |

spectralDecomp object after truncating trailing eigen values

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 | ```
N = 10 # samples
P = 20 # features
# Simulate feature matrix
X = matrix(rnorm(N*P), N, P)
# Scale feature matrix
X = scale(X) / sqrt(N-1)
# Compute SVD of feature matrix
dcmp = svd(X, nu=0)
# Compute correlation and squared correlation matrices
# This is O(P^2)
C = crossprod(X)
Csq = C^2
# Compute SVD of Csq using only the svd of C
# this is faster than O(PN^4)
# if R is the rank of X
# Time is O(P (choose(N,2) + N)^4)
dcmp_C2 = correlationSquaredDecomp( dcmp$v, dcmp$d )
# set rank to 3
dcmp_C2_truncate = setDecompRank(dcmp_C2, rank = 3)
# retain 90% of total variance
dcmp_C2_truncate = setDecompRank(dcmp_C2, varianceFraction = 0.9)
``` |

GabrielHoffman/pinnacle documentation built on May 3, 2019, 3:02 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.