Learn R Programming

deal (version 1.1-15)

network: Bayesian network data structure

Description

A Bayesian network is represented as an object of class network. Methods for printing and plotting are defined.

Usage

network(df,specifygraph=FALSE,inspectprob=FALSE,
        doprob=TRUE,yr=c(0,350),xr=yr) 
## S3 method for class 'network':
print(x,filename=NA,master=FALSE,condposterior=FALSE,
                          condprior=FALSE,...) 
## S3 method for class 'network':
plot (x,scale=10,arrowlength=.25,
                        notext=FALSE,
                        sscale=.7*scale,showban=TRUE,yr=c(0,350),xr=yr,
                        unitscale=20,cexscale=8,...)

prob.network (x,df)

Arguments

df
A data frame, where the columns define the variables. A continuous variable should have type numeric and discrete varibles should have type factor.
specifygraph
Interactively specify a directed acyclic graph and possibly a ban list (see below).
inspectprob
Inspect the calculated probability distribution using a graphical interface.
doprob
If TRUE, do not calculate a probability distribution. Used for example in simulation.
x
The network.
filename
If a string argument is given, output is printed to a file.
condprior
Print condprior? TRUE/FALSE
condposterior
Print condposterior? TRUE/FALSE
master
Print master? TRUE/FALSE.
scale
The axes in network plots are from -scale to scale.
sscale
The nodes are placed on a circle with radius sscale.
unitscale
Scale parameter for chopping off arrow heads.
cexscale
The size of the nodes.
arrowlength
The length of the arrow heads.
xr
Range of x-axis.
yr
Range of y-axis.
notext
No text is displayed in the nodes on the plot if notext is TRUE
rotate
The nodes are placed on a circle and they may be rotated by this number (in radians).
showban
If banned arrows should be shown (they are shown in red).
...
Passed to plot.node.

Value

  • A network object with attributes
  • nodesA list of nodes. If doprob==TRUE, the nodes are given the attribute prob which is the initial probability distribution used by jointprior.
  • nThe number of nodes.
  • discreteA vector of indices of discrete nodes.
  • continuousA vector of indices of continuous nodes.
  • banlistA matrix with two columns. Each row contains the indices i -> j of arrows that may not be allowed in the directed acyclic graph.
  • scoreAdded by learn and is the log network score.
  • relscoreAdded by nwfsort and is the relative log network score -- compared with the best network in a network family.

References

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

See Also

networkfamily, node, simulation, learn, drawnetwork, jointprior, heuristic, nwequal

Examples

Run this code
A <- factor(rep(c("A1","A2"),50))
B <- factor(rep(rep(c("B1","B2"),25),2))
thisnet <- network( data.frame(A,B) )

Run the code above in your browser using DataLab