R/corrMatgen.R

Defines functions `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 MCPAN package in your browser

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

MCPAN documentation built on May 1, 2019, 8:04 p.m.