#' Sample Correlation
#'
#' @param x a matrix
#'
#' @return rik the sample correlation
#' @export
#'
#' @examples samp_cor(matrix(1:9,nrow=3))
samp_cor = function(x) {
p = ncol(x)
rik <- matrix(NA, nr=p, nc=p)
xcov = samp_cov(x)
for(i in 1:p) {
for(k in 1:p) {
rik[i,k] = xcov[i,k] / (sqrt(xcov[i,i])*sqrt(xcov[k,k]))
}
}
return(rik)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.