0

I derive data from a multivariate normal distribution. I created the correlation structure I wanted by the sigma matrix. Since I take the standard deviation as 1, I expect the Sigma matrix and correlation of Z matrix to be the same, but it is not the same. how do i solve this problem? So, how can I derive data from the multivariate normal distribution according to the correlation matrix I want?

  blck1 <- c(1:8)
  blck2 <- c(9:20)
  pr <- seq(0.05, 0.01, length.out = 20)
  Sigma <- toeplitz(pr)

  #### Blok1 ###############
  pr_blck1 <- seq(0.7, 0.3, length.out = length(blck1))
  Sigma_blck1 <- toeplitz(pr_blck1)
  Sigma[blck1, blck1] <-  Sigma_blck1
  diag(Sigma) <- 1
  
 Z <- rmvnorm(n= 50, 
               mean  = rep(0, 20), 
               sigma = Sigma )
 
Sigma
cor(Z)
  • I don't know if you've done this correctly, but to check if two correlations are the same, you need to have `Z` come from a very large `n`. If I use `n = 500e3`, then I get: `> mean((Sigma - cor(Z))**2) [1] 1.889569e-06 ` – Mossa Jun 14 '22 at 12:00
  • thank you for the answer. I actually want to have correlations between the variables in the order I determine. I'm not interested in mean correlation or error. What I want to do here is that block1 should be moderately-highly correlated in itself, and block 2 should be low-correlated within itself and with block 1. However, I could not find such an arrangement. – Bugra Varol Jun 15 '22 at 07:43

0 Answers0