根据R中的特定相关矩阵从多元正态分布中得出数据
我从多元正态分布中得出数据。我创建了Sigma矩阵所需的相关结构。由于我以标准偏差为1,因此我希望Sigma矩阵和Z矩阵的相关性是相同的,但不是相同的。如何解决这个问题?那么,如何根据我想要的相关矩阵从多元正态分布中得出数据?
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 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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论