# 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)
# }
Run the code above in your browser using DataLab