#' function for computing shrinkage for low-rank matrix
#'
#' compute the soft-thresholded result for the low-rank estimator
#' @param y An input vector, singular values vector of target matrix
#' @param tau A float number, which stands for the threshold
#' @return A thresholded singular value vector based on input matrix and threshold
#' @details This function is to find the soft-thresholded singular value vector for low rank component. The input vector is derived by SVD.
#' @examples
#' set.seed(100)
#' M <- matrix(stats::rnorm(15), 5, 3)
#' y <- svd(M)$d
#' tau <- 0.5
#' shrinkage_lr(y, tau) ### this vector is thresholded singular value vector.
#' @export
shrinkage_lr <- function(y, tau){
z <- rep(0, length(y))
for(i in 1:length(y)){
z[i] <- sign(y[i]) * max(0, abs(y[i]) - tau)
}
return(z)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.