Bayesian network data structure
A Bayesian network is represented as an object of class
network
. Methods for printing and plotting are defined.
network(df,specifygraph=FALSE,inspectprob=FALSE, doprob=TRUE,yr=c(0,350),xr=yr) ## S3 method for class 'network' print(x,filename=NA,condposterior=FALSE, condprior=FALSE,...) ## S3 method for class 'network' plot(x,arrowlength=.25, notext=FALSE, sscale=7,showban=TRUE,yr=c(0,350),xr=yr, unitscale=20,cexscale=8,...)
df |
a data frame, where the columns define the variables. A
continuous variable should have type |
specifygraph |
a logical. If |
inspectprob |
a logical. If |
doprob |
a logical. If |
x |
an object of class |
filename |
a string or |
condprior |
a logical. If |
condposterior |
a logical. If |
sscale |
a numeric. The nodes are initially placed on a circle
with radius |
unitscale |
a numeric. Scale parameter for chopping off arrow heads. |
cexscale |
a numeric. Scale parameter to set the size of the nodes. |
arrowlength |
a numeric containing the length of the arrow heads. |
xr |
a numeric vector with two components containing the range on x-axis. |
yr |
a numeric vector with two components containing the range on y-axis. |
notext |
a logical. If |
showban |
a logical. If |
... |
additional plot arguments, passed to |
The netork
creator function returns an object of class
network
, which is a list with the following
elements (properties),
nodes |
a list of objects of class |
n |
an integer containing the number of nodes in the network. |
discrete |
a numeric vector of indices of discrete nodes. |
continuous |
a numeric vector of indices of continuous nodes. |
banlist |
a numeric matrix with two columns. Each row contains the
indices |
score |
a numeric added by |
relscore |
a numeric added by |
Susanne Gammelgaard Bottcher,
Claus Dethlefsen rpackage.deal@gmail.com.
A <- factor(rep(c("A1","A2"),50)) B <- factor(rep(rep(c("B1","B2"),25),2)) thisnet <- network( data.frame(A,B) ) set.seed(109) sex <- gl(2,4,label=c("male","female")) age <- gl(2,2,8) yield <- rnorm(length(sex)) weight <- rnorm(length(sex)) mydata <- data.frame(sex,age,yield,weight) mynw <- network(mydata) # adjust prior probability distribution localprob(mynw,"sex") <- c(0.4,0.6) localprob(mynw,"age") <- c(0.6,0.4) localprob(mynw,"yield") <- c(2,0) localprob(mynw,"weight")<- c(1,0) print(mynw) plot(mynw) prior <- jointprior(mynw) mynw <- getnetwork(learn(mynw,mydata,prior)) thebest <- getnetwork(autosearch(mynw,mydata,prior)) print(mynw,condposterior=TRUE) ## Not run: savenet(mynw,file("yield.net"))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.