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)
}

Try the ILSE package in your browser

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

ILSE documentation built on Jan. 31, 2022, 9:06 a.m.