Description Usage Arguments Value Author(s) Examples
Estimates the conditional probability tables for bayesian network models, where the structure is given by an adjacency matrix.
1 |
adj_matrix |
The adjacency matrix for the DAG. |
data |
The data the probabilities should be estimated from. |
bayes_smooth |
The additional cell counts for bayesian estimation of probability tables. |
A list of the conditional probability tables for the
bayesian network. If the bayes_smooth
argument is zero,
it is the maximum likelihood estimates. Otherwise, it is bayesian
estimates.
Katrine Kirkeby, enir_tak@hotmail.com
Maria Knudsen, mariaknudsen@hotmail.dk
Ninna Vihrs, ninnavihrs@hotmail.dk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | set.seed(43)
var1 <- c(sample(c(1, 2), 50, replace = TRUE))
var2 <- var1 + c(sample(c(1, 2), 50, replace = TRUE))
var3 <- var1 + c(sample(c(0, 1), 50, replace = TRUE,
prob = c(0.9, 0.1)))
var4 <- c(sample(c(1, 2), 50, replace = TRUE))
data <- data.frame("var1" = as.character(var1),
"var2" = as.character(var2),
"var3" = as.character(var3),
"var4" = as.character(var4))
adj_matrix_DAG <- matrix(c(0, 0, 0, 0,
1, 0, 0, 0,
1, 0, 0, 0,
0, 1, 0, 0),
nrow = 4)
rownames(adj_matrix_DAG) <- colnames(adj_matrix_DAG) <- names(data)
CPT(adj_matrix_DAG, data)
CPT(adj_matrix_DAG, data, bayes_smooth = 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.