Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

insert

Insert/remove an arrow in network


Description

Inserts/removes one arrow in a network (if legal)

Usage

insert (nw,j,i,df,prior,nocalc=FALSE,trylist=vector("list",size(nw))) 
remover(nw,j,i,df,prior,nocalc=FALSE,trylist=vector("list",size(nw)))

Arguments

nw

an object of class network.

j

integer, giving the index of the 'from' node.

i

integer, giving the index of the 'to' node.

df

a data frame used for learning the network, see network.

prior

a list describing parameter priors, generated by jointprior.

nocalc

a logical. If TRUE, learning is not called.

trylist

a list, used internally for reusing learning of nodes, see maketrylist.

Details

Examines if the arrow from j to i is legal according to the following criteria

Arrows from/to the same node are not legal.

Arrows from continous nodes to discrete nodes are not legal.

Arrows banned in ban list are not legal, see drawnetwork.

Arrows already existing in the network are not legal.

If the arrow is not legal, a NULL network is returned. Otherwise, the arrow is inserted/removed, the network is re-learned (if nocalc is FALSE). The trylist is updated.

Value

A list with two elements

nw

an object of class network with the arrow added/removed if this is possible. If not, NULL is returned.

trylist

an updated list, used internally for reusing learning of nodes, see maketrylist.

Author(s)

Susanne Gammelgaard Bottcher,
Claus Dethlefsen rpackage.deal@gmail.com.

Examples

data(rats)
rats.nw    <- network(rats)
rats.nw    <- getnetwork(insert(rats.nw,2,1,nocalc=TRUE))
rats.prior <- jointprior(rats.nw,12)

rats.nw2   <- network(rats)
rats.nw2   <- getnetwork(learn(rats.nw2,rats,rats.prior))
rats.nw2   <- getnetwork(insert(rats.nw2,1,2,rats,rats.prior))

rats.nw3   <- getnetwork(remover(rats.nw2,1,2,rats,rats.prior))

deal

Learning Bayesian Networks with Mixed Variables

v1.2-39
GPL (>= 2)
Authors
Susanne Gammelgaard Bottcher, Claus Dethlefsen.
Initial release
2018-10-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.