Description Usage Arguments Details Value Examples
Convert a partial correlation matrix to a data matrix using Cholesky decomposition.
1 | pcm2data(pcm, n = 10000)
|
pcm |
A partial correlation matrix. |
n |
Integer. The number of observations in the output data. |
Use the Cholesky decomposition to generate data from a partial correlation matrix.
A data matrix, of dimensions n
and ncol(pcm)
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ggm <- matrix(
c(0, 1, 1, 0,
1, 0, 1, 1,
1, 1, 0, 1,
0, 1, 1, 0), ncol = 4)
pcm <- ggm2pcm(ggm, minpcor = 0.2, maxpcor = 0.9, maxiter = 1000, verbose = FALSE)
dat <- pcm2data(pcm, n = 1000)
# plot
par(mfrow = c(3,1))
net1 <- qgraph(ggm)
title(main = "adjacency matrix")
qgraph(pcm, layout = net1$layout)
title(main = "original pcm")
qgraph(cor2pcor(cor(dat)), layout = net1$layout)
title(main = "pcm reproduced by data")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.