Description Usage Arguments Details Value Author(s) Examples
An adjacency matrix is converted to a weighted partial correlation matrix, with positive-definiteness as a condition.
1 |
ggm |
Adjacecny matrix, elements in -1, 0, 1. |
minpcor |
Numeric. Minimum allowed value for partial correlation. |
maxpcor |
Numeric. Maximum allowed value for partial correlation. |
maxiter |
Integer. Maximum number of attempts to get a positive definite matrix. |
verbose |
Logical. Specify whether the function inform you of each iteration. |
At each iteration, a candidate partial correlation matrix is created by drawing numbers from an uniform distribution from minpcor to maxpcor. If the matrix is positive definite and the correlation matrix implied is also positive definite, the matrix is returned in output. If positive-definiteness cannot be reaced after maxiter iterations, a non positive-definite matrix is returned with a warning.
pcm, a partial correlation matrix with the same conditional independencies specified in the adjacency matrix ggm given as input.
Giulio Costantini, Lourens Waldorp
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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)
# plot the two matrices
par(mfrow = c(1,2))
net1 <- qgraph(ggm)
title(main = "adjacency matrix")
qgraph(pcm, layout = net1$layout)
title(main = "partial correlation matrix")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.