Learn R Programming

deal (version 1.2-4)

addrandomarrow: Adding/Turning/Removing random arrows

Description

Create network with exactly one arrow added/turned/removed randomly chosen.

Usage

addrandomarrow(nw,data,prior,trylist=vector("list",nw$n),nocalc=FALSE,
               timetrace=FALSE)
turnrandomarrow(nw,data,prior,trylist=vector("list",nw$n),nocalc=FALSE,
               timetrace=FALSE)
deleterandomarrow(nw,data,prior,trylist=vector("list"),nw$n),nocalc=FALSE,
               timetrace=timetrace)

Arguments

nw
an object of class network, from which arrows are added/removed/turned.
data
a data frame used for learning the network, see network.
prior
a list describing parameter priors, generated by jointprior.
trylist
a list, used internally for reusing learning of nodes, see maketrylist.
nocalc
a logical. if TRUE, the learning procedure is not called. Used if only a random graph is wanted.
timetrace
a logical. If TRUE, prints some timing information on the screen.

Value

  • A list with two elements
  • nwan object of class networkfamily with all created networks. All networks have been learned.
  • trylistan updated list, used internally for reusing learning of nodes, see maketrylist.

Details

Given the starting network, a network is created with exactly one arrow added/turned/removed. The arrow is chosen randomly amongst all possibilities. If there are no possibilities, the original network is returned. All networks are learned with the data in df using the prior information in prior. Used by perturb.

References

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

See Also

perturb

Examples

Run this code
data(rats)
fit       <- network(rats,specifygraph=FALSE,inspect=FALSE)
fit.prior <- jointprior(fit,12)
fit       <- learn(fit,rats,fit.prior)$nw
set.seed(10)
rats.extra <- addrandomarrow(fit,rats,fit.prior)$nw
rats.extra <- addrandomarrow(rats.extra,rats,fit.prior)$nw
rats.extra <- turnrandomarrow(rats.extra,rats,fit.prior)$nw
rats.extra <- deleterandomarrow(rats.extra,rats,fit.prior)$nw
plot(rats.extra)

Run the code above in your browser using DataLab