R/corrmatgen.R

Defines functions corrmatgen

Documented in corrmatgen

corrmatgen <- function(CM,varp)
  {
    k <- ncol(CM)
    if( length(varp) != k )
      {stop("number of columns and length of var must be the same")}
    l <- nrow(CM)
    cor <- matrix(0, ncol=l, nrow=l)
    for(i in 1:l)
      {
        for(j in 1:l)
          {
            cor[i,j]<-sum( CM[i,]*CM[j,]*varp ) / sqrt( sum( (CM[i,]^2)*varp ) * sum( (CM[j,]^2)*varp ) )
          }
      }
    return(cor)
  }

Try the simboot package in your browser

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

simboot documentation built on May 2, 2019, 9:14 a.m.