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

perturb

Perturbs a network


Description

Randomly insert/delete/turn arrows to obtain another network.

Usage

perturb(nw,data,prior,degree=size(nw),trylist=vector("list",size(nw)),
        nocalc=FALSE,timetrace=TRUE)

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 containing parameter priors, generated by jointprior.

degree

an integer, which gives the number of attempts to randomly insert/remove/turn an arrow.

trylist

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

nocalc

a logical. If TRUE no learning procedure is called, see eg. rnetwork.

timetrace

a logical. If TRUE, prints some timing information on the screen.

Details

Given the initial network, a new network is constructed by randomly choosing an action: remove, turn, add. After the action is chosen, we choose randomly among all possibilities of that action. If there are no possibilites, the unchanged network is returned.

Value

A list with two elements that may be accessed using getnetwork and gettrylist. The elements are

nw

an object of class network with the generated network.

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

set.seed(200)
data(rats)
fit       <- network(rats)
fit.prior <- jointprior(fit)
fit       <- getnetwork(learn(fit,rats,fit.prior))
fit.new   <- getnetwork(perturb(fit,rats,fit.prior,degree=10))

data(ksl)
ksl.nw    <- network(ksl)
ksl.rand  <- getnetwork(perturb(ksl.nw,nocalc=TRUE,degree=10))
plot(ksl.rand)

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.