R/cor.mat.R

Defines functions cor.mat

Documented in cor.mat

cor.mat <- function(p, rho, type='toeplitz'){

  mat <- diag(p)
  if(type=='toeplitz'){
    for(i in 2:p){
      for(j in 1:i){
        mat[i,j] <- mat[j,i] <- rho^(abs(i-j))
      }
    }
  }
  if(type=='identity'){
    mat[mat==0] <- rho
  }
  return(mat)
}
feiyoung/simutool documentation built on Sept. 15, 2021, 10:14 p.m.