ggm.simulate.pcor: Graphical Gaussian Models: Simulation of Networks

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

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

Description

ggm.simulate.pcor generates a random matrix of partial correlations that corresponds to a GGM network of a given size (num.nodes) with a specified fraction of non-zero edges. The diagonal entries of the output matrix contain 1.

If stdprec=TRUE then the standardised precision matrix is returned instead of the patrix of partial correlations.

Usage

1
ggm.simulate.pcor(num.nodes, etaA=0.05, stdprec=FALSE)

Arguments

num.nodes

number of nodes in the network

etaA

fraction of edges with non-zero partial correlation (default: 0.05)

stdprec

return standardised precision matrix, rather than matrix of partial correlations

Details

The simulation of the partial correlation matrix works by generating a diagonally dominant matrix as a positive definite precision matrix (inverse covariance matrix), which is subsequently standardized and transformed into the matrix of partial correlations. For the full algorithm see Sch\"afer and Strimmer (2005).

Value

A positive partial correlation matrix (diagonal 1) with positive definite underlying precision matrix.

If stdprec=TRUE then the standardised precision matrix is returned instead.

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.data,ggm.estimate.pcor.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Not run: 

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


## End(Not run)

Example output

Loading required package: corpcor
Loading required package: longitudinal
Loading required package: fdrtool
[1] 815.7756
Estimating optimal shrinkage intensity lambda (correlation matrix): 0.4113 

[1] 10.07027

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