Learn R Programming

NetworkToolbox (version 1.4.2)

sim.chordal: Simulate Chordal Network

Description

Simulates a chordal network based on number of nodes. Data will also be simulated based on the true network structure

Usage

sim.chordal(
  nodes,
  inverse = c("cases", "matrix"),
  n = NULL,
  ordinal = FALSE,
  ordLevels = NULL,
  idio = NULL,
  eps = NULL
)

Arguments

nodes

Numeric. Number of nodes in the simulated network

inverse

Character. Method to produce inverse covariance matrix.

  • "cases"Estimates inverse covariance matrix based on n number of cases and nodes number of variables, which are drawn from a random normal distribution rnorm. Data generated will be continuous unless ordinal is set to TRUE

  • "matrix"Estimates inverse covariance matrix based on ??eps??

n

Numeric. Number of cases in the simulated dataset

ordinal

Boolean. Should simulated continuous data be converted to ordinal? Defaults to FALSE. Set to TRUE for simulated ordinal data

ordLevels

Numeric. If ordinal = TRUE, then how many levels should be used? Defaults to 5. Set to desired number of intervals

idio

Numeric. DESCRIPTION. Defaults to 0.10

eps

Numeric. DESCRIPTION. Defaults to 2

Value

Returns a list containing:

cliques

The cliques in the network

separators

The separators in the network

inverse

Simulated inverse covariance matrix of the network

data

Simulated data from sim.correlation in the psych package based on the simulated network

References

Massara, G. P. & Aste, T. (2019). Learning clique forests. ArXiv.

Examples

Run this code
# NOT RUN {
#Continuous data
sim.Norm <- sim.chordal(nodes = 20, inverse = "cases", n = 1000)

#Ordinal data
sim.Likert <- sim.chordal(nodes = 20, inverse = "cases", n = 1000, ordinal = TRUE)

#Dichotomous data
sim.Binary <- sim.chordal(nodes = 20, inverse = "cases", n = 1000, ordinal = TRUE, ordLevels = 5)

# }

Run the code above in your browser using DataLab