ggm.simulate.data: Graphical Gaussian Models: Simulation of Data

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/ggm.simulate.data.R

Description

ggm.simulate.data takes a positive definite partial correlation matrix and generates an i.i.d. sample from the corresponding standard multinormal distribution (with mean 0 and variance 1). If the input matrix pcor is not positive definite an error is thrown.

Usage

1
ggm.simulate.data(sample.size, pcor)

Arguments

sample.size

sample size of simulated data set

pcor

partial correlation matrix

Value

A multinormal data matrix.

Author(s)

Juliane Sch\"afer and Korbinian Strimmer (https://strimmerlab.github.io).

References

Sch\"afer, J., and Strimmer, K. (2005). An empirical Bayes approach to inferring large-scale gene association networks. Bioinformatics 21:754-764.

See Also

ggm.simulate.pcor, ggm.estimate.pcor.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# load GeneNet library
library("GeneNet")

# generate random network with 40 nodes 
# it contains 780=40*39/2 edges of which 5 percent (=39) are non-zero
true.pcor <- ggm.simulate.pcor(40)
  
# simulate data set with 40 observations
m.sim <- ggm.simulate.data(40, true.pcor)

# simple estimate of partial correlations
estimated.pcor <- cor2pcor( cor(m.sim) )

# comparison of estimated and true values
sum((true.pcor-estimated.pcor)^2)

# a slightly better estimate ...
estimated.pcor.2 <- ggm.estimate.pcor(m.sim)
sum((true.pcor-estimated.pcor.2)^2)

GeneNet documentation built on Nov. 15, 2021, 1:07 a.m.