Description Usage Arguments Value Examples
data generating function
1 2 3 4 5 6 7 8 | generate_discrete_data(
graph,
params,
n,
ivn = NULL,
ivn.rand = TRUE,
n_levels = NULL
)
|
graph |
A |
params |
Coefficient list. |
n |
Size of the data set, a scalar |
ivn |
List of interventions. |
ivn.rand |
If |
n_levels |
A vector of number of levels for each node. Default is binary data. |
data matrix
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ### generate observational data
gr <- sparsebnUtils::random.graph(5, 5) # use sparsebnUtils package to generate a random graph
names(gr) = c("V1", "V2", "V3", "V4", "V5")
nlevels <- c(3, 5, 2, 2, 3)
gr.params <- coef_gen(edge_list = gr, n_levels = nlevels)
data.obs <- discretecdAlgorithm::generate_discrete_data(graph = gr,
n = 100,
n_levels = nlevels,
params = gr.params)
### generate experimental data
ivn <- as.list(c(rep("V1", 50), rep("V2", 50))) # 50 interventions on V1, 50 interventions on V2
data.ivn <- discretecdAlgorithm::generate_discrete_data(graph = gr,
n = 100,
n_levels = nlevels,
params = gr.params,
ivn = ivn)
### Use pre-specified values for interventions
### In this toy example, we assume that all intervened nodes were fixed to
### to the value 1, although this can be any number of course.
ivn.vals <- lapply(ivn, function(x) sapply(x, function(x) 1)) # replace all entries with a 1
data.ivn <- discretecdAlgorithm::generate_discrete_data(graph = gr,
n = 100,
n_levels = nlevels,
params = gr.params,
ivn = ivn.vals,
ivn.rand = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.