Skip to contents

Singular value thresholding evaluates the optimal number of singular values to retain

Usage

sv_threshold(n, p, d)

Arguments

n

number of samples

p

number of features

d

singular values

Value

Number of singular values to retain

References

Gavish, M., & Donoho, D. L. (2014). The optimal hard threshold for singular values is 4/sqrt(3). IEEE Transactions on Information Theory, 60(8), 5040-5053.

Examples

# simulate data

n <- 500
p <- 5000
Y <- Rfast::matrnorm(n, p, seed = 1)

# SVD
dcmp <- svd(Y)

# how many components to retain
sv_threshold(n, p, dcmp$d)
#> [1] 0

# in this case the data has no structure, so no components are retained