ggm2pcm: Convert an adjacency matrix to a partial correlation matrix.

Description Usage Arguments Details Value Author(s) Examples

Description

An adjacency matrix is converted to a weighted partial correlation matrix, with positive-definiteness as a condition.

Usage

1
ggm2pcm(ggm, minpcor = 0.2, maxpcor = 0.9, maxiter = 1000, verbose = FALSE)

Arguments

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.

Details

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.

Value

pcm, a partial correlation matrix with the same conditional independencies specified in the adjacency matrix ggm given as input.

Author(s)

Giulio Costantini, Lourens Waldorp

Examples

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

GiulioCostantini/TOMproject documentation built on May 6, 2019, 6:29 p.m.