pcm2data: Partial correlation matrix to data.

Description Usage Arguments Details Value Examples

Description

Convert a partial correlation matrix to a data matrix using Cholesky decomposition.

Usage

1
pcm2data(pcm, n = 10000)

Arguments

pcm

A partial correlation matrix.

n

Integer. The number of observations in the output data.

Details

Use the Cholesky decomposition to generate data from a partial correlation matrix.

Value

A data matrix, of dimensions n and ncol(pcm).

Examples

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

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