R/psdcor.R

Defines functions psdcor

Documented in psdcor

psdcor <- function(m, method = c("higham", "eigen"), ...) {
  method <- match.arg(method)
  m <- as.matrix(m)
  if (length(m) <= 1) {
    ret <- m
  } else {
    ret <- switch(method,
      eigen = {
        sfsmisc::posdefify(m, ...)
      },
      higham = {
        sfsmisc::nearcor(m, ...)$cor
  #      require(Matrix);
  #      as.matrix(nearPD(m, corr=TRUE, ...)$mat)
      }
    )
  }
  ret
}

Try the robcor package in your browser

Any scripts or data that you put into this service are public.

robcor documentation built on June 27, 2022, 9:06 a.m.