#' function to compute the value of low-rank penalty term, i.e. nuclear norm.
#' @param x x is the input m by n matrix
#' @param lambda tuning parameter for nuclear norm penalty
#' @return a float number that represents the value of penalty.
#' @details This function is to compute the low rank penalty via nuclear norm
#' @examples
#' x <- matrix(stats::rnorm(20), 5, 4)
#' lambda <- 0.75
#' nuclear_pen(x, lambda)
#' @export
nuclear_pen <- function(x, lambda){
d <- svd(x)$d
return(lambda * sum(d))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.