Learn R Programming

deal (version 1.1-1)

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,equalcases=FALSE,vif=1.0,
        doprob=TRUE,tvar=NA,smalldf=NA,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,equalcases=FALSE,vif=1.0,smalldf=NA)

Arguments

df
A dataframe, 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 banlist (see below).
inspectprob
Inspect/change the calculated probability distribution using a graphical interface.
equalcases
When calculating the probability distribution for discrete variables, do not (if TRUE) set the probability equal to the observed frequency. If FALSE, observed frequencies are used.
vif
Variance inflation factor. For continuous nodes, the probability distribution is assumed normal with a mean depending on the parents and a variance for each configuration of the discrete parents. The mean and variance are deduced from data
doprob
If TRUE, do not calculate a probability distribution. Used for example in simulation.
tvar
Vector of indices of time-varying nodes, see timeslice.
smalldf
For use with timevarying networks, see timeslice.
x
The network.
filename
Print to 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 (or little) text is displayed on the plot if notext==TRUE.
rotate
The nodes are placed on a circle and this 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. Arguments equalcases and vif are used to calculate prob.
  • 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 to the best network in a networkfamily.

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