R/corFunction.r

Defines functions corFunction

Documented in corFunction

####################
# Function to calculate the correlations from the precision matrix
####################
corFunction = function(McmcArray, Parameter,this.names, Model) {
  nchains = dim(McmcArray)[2]
  cors = matrix(NA, nrow = dim(McmcArray)[1], ncol = nchains)
  # Shortcut for calculating correlation of 2x2
  # Matrix A = [a b c d]
  # Ainv = 1/(ad -bc)*[d -b -c a], cor = -b/sqrt(d*a)
  for(i in 1:nchains) {
    thisMat = McmcArray[,i,grep(this.names,Model$Parameter)]
    cors[,i] = -thisMat[,3]/sqrt(thisMat[,1]*thisMat[,4])
  }
  return(cors)
}

Try the nwfscDeltaGLM package in your browser

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

nwfscDeltaGLM documentation built on May 2, 2019, 6:30 p.m.