Learn R Programming

deal (version 1.1-1)

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=rep(list(NULL),nw$n)) 
remover(nw,j,i,df,prior,nocalc=FALSE,trylist=rep(list(NULL),nw$n))

Arguments

nw
A network.
j
The 'from' node.
i
The 'to' node.
df
Data Frame used for learning the network, see network.
prior
A joint prior, see jointprior.
nocalc
If TRUE, learning is not called.
trylist
Used internally for reusing learning of nodes, see maketrylist.

Value

  • A list with two elements
  • nwA network family with all created networks.
  • trylistUpdated.

Details

Examines if the arrow from j to i is legal according to the following criteria 1.{Arrows from/to the same node are not legal.} 2.{Arrows from continous nodes to discrete nodes are not legal.} 3.{Arrows banned in ban list are not legal, see drawnetwork.} 4.{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=F). The trylist is updated.

References

Further information about Deal can be found at: http://www.math.auc.dk/novo/deal.

Examples

Run this code
data(rats)
rats.nw    <- network(rats)
rats.nw    <- insert(rats.nw,2,1,nocalc=TRUE)$nw
rats.prior <- jointprior(rats.nw,12)

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

Run the code above in your browser using DataLab