Description Usage Arguments Value Examples
Given the structure of a Bayesian network, estimate the parameters
using multinomial logistic regression. For each node i, regress
i onto its parents set using multinom
in package nnet
.
1 | fit_multinom_dag(parents, dat)
|
parents |
An |
dat |
Data, a dataframe or matrix |
A list with with one component for each node in the graph. Each node is a coefficient matrix for the parents of that node.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ### construct a random data set
x <- c(0,1,0,1,0)
y <- c(1,0,1,0,1)
z <- c(0,1,2,1,0)
a <- c(1,1,1,0,0)
b <- c(0,0,1,1,1)
dat <- data.frame(x, y, z, a, b)
### randomly construct an edgelist of a graph
nnode <- ncol(dat)
li <- vector("list", length = nnode)
li[[1]] <- c(2L,4L)
li[[2]] <- c(3L,4L,5L)
li[[3]] <- integer(0)
li[[4]] <- integer(0)
li[[5]] <- integer(0)
edgeL <- edgeList(li)
### run fit_multinom_dag
fit.multinom <- fit_multinom_dag(edgeL, dat)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.