network                 package:deal                 R Documentation

_B_a_y_e_s_i_a_n _n_e_t_w_o_r_k _d_a_t_a _s_t_r_u_c_t_u_r_e

_D_e_s_c_r_i_p_t_i_o_n:

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

_U_s_a_g_e:

     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,...)

_A_r_g_u_m_e_n_t_s:

      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: a logical. If 'TRUE', provides a call to 'drawnetwork' to
          interactively specify a directed acyclic graph and possibly a
          ban list (see below).

inspectprob: a logical. If 'TRUE', provides a plot of the graph and
          possibility to inspect the calculated probability
          distribution by clicking on the nodes.

  doprob: a logical. If 'TRUE', do not calculate a probability
          distribution. Used  for example in 'rnetwork'. 

       x: an object of class 'network'.

filename: a string or 'NA'. If not 'NA', output is printed to a file.

condprior: a logical. If 'TRUE', the conditional prior is printed, see
          'conditional'.

condposterior: a logical. If 'TRUE', the conditional posterior is
          printed, see 'learn'.

  sscale: a numeric. The nodes are initially placed on a circle with
          radius 'sscale'.

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 'TRUE', no text is displayed in the nodes on
          the plot.

 showban: a logical. If 'TRUE', banned arrows are shown in red.

     ...: additional plot arguments, passed to 'plot.node'.

_V_a_l_u_e:

     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 'node'. If 'doprob' is 'TRUE', the
          nodes are given the  property 'prob' which is the initial
          probability distribution used by 'jointprior'.

       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 'i -> j' of arrows that may not be allowed in the
          directed acyclic graph.

   score: a numeric added by 'learn' and is the log network score.

relscore: a numeric added by 'nwfsort' and is the relative network
          score - compared with the best network in a network family.

_A_u_t_h_o_r(_s):

     Susanne Gammelgaard Bttcher alma@math.aau.dk, 
      Claus Dethlefsen cld@rn.dk.

_R_e_f_e_r_e_n_c_e_s:

     Further information about *deal* can be found at:
      <URL: http://www.math.aau.dk/~dethlef/novo/deal>.

_S_e_e _A_l_s_o:

     'networkfamily', 'node', 'rnetwork', 'learn', 'drawnetwork',
     'jointprior', 'heuristic', 'nwequal'

_E_x_a_m_p_l_e_s:

     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"))

