autosearchEx             package:BNArray             R Documentation

_G_r_e_e_d_y _s_e_a_r_c_h

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

     From initial network, does local perturbations to increase network
     score.

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

     autosearchEx(initnw,data,prior=jointprior(network(data)),maxiter=50,
                trylist= vector("list",size(initnw)),trace=TRUE,
                timetrace=TRUE,showban=FALSE,removecycles=FALSE) 

     heuristicEx(initnw,data,prior=jointprior(network(data)),
               maxiter=100,restart=10,degree=size(initnw),
               trylist= vector("list",size(initnw)),trace=TRUE,
               timetrace=TRUE,removecycles=FALSE)

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

  initnw: an object of class 'network', from which the search is
          started. 

    data: a data frame used for learning the network, see 'network'.

   prior: a list containing parameter priors, generated by
          'jointprior'.

 maxiter: an integer, which gives the maximum number of steps in the
          search algorithm.

 restart: an integer, which gives the number of times to perturb
          'initnw' and rerun the  search.

  degree: an integer, which gives the degree of perturbation, see
          '\perturb'.

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

   trace: a logical. If 'TRUE', plots the accepted networks during
          search.

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

 showban: a logical passed to  the plot method for network objects. If
          'FALSE', the banned arrows are not shown in the plots (if
          'trace' is 'TRUE').

removecycles: a logical. If 'TRUE', all networks explored in the search
          is returned, except for networks containing a cycle. If
          'FALSE', all networks are returned, including cyclic
          networks.

       x: an output object from a search.

_D_e_t_a_i_l_s:

     In 'autosearchEx', a list of networks is in each step created with
     either one arrow added, one arrow deleted or one arrow turned (if
     a cycle is not generated). The network scores of all the proposal
     networks are calculated and the network with the highest score is
     chosen for the next step in the search. If no proposed network has
     a higher network score than the previous network, the search is
     terminated. The network with the highest network score is
     returned, along with a list containing all tried networks
     (depending on the value of 'removecycles').

     'heuristicEx' restarts by perturbing 'initnw' 'degree' times and
     calling  'autosearchEx' again. The number of restarts is given by
     the option 'restart'.

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

     'autosearchEx' and 'heuristicEx' returns a list with three
     elements, that may be accessed using 'getnetwork', 'gettable' and
     'gettrylist'. The elements are 

      nw: an object of class 'network', which gives the network with
          the highest score.

   table: a table with all tried networks. If removecycles is 'FALSE',
          the networks may contain cycles. The table contains two
          columns: 'model' with a  string representation of the model
          and 'score' with the corresponding log network score. The
          table can be translated to a 'networkfamily' using 'makenw'.

 trylist: an updated list used internally for reusing learning of
          nodes, see 'maketrylist'.

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

     Susanne Gammelgaard B鴗tcher alma@math.aau.dk, 
      Claus Dethlefsen aas.claus.dethlefsen@nja.dk 
      Xiaohui Chen cxh1984@interchange.ubc.ca, 
      Kaida Ning aprilnkd@hotmail.com, 
      Ming Chen mchen@zju.edu.cn.

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

     Further information about *BNArray* can be found at:
      <URL: http://www.math.aau.dk/~dethlef/novo/deal> 
      <URL: http://www.cls.zju.edu.cn/binfo/BNArray>.

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

     'perturb'

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

     ## Not run: 
             library(BNArray)
             data(total.data)
             setwd("/home")  #for linux user

     ##SHOULD call LLSimpute first
     ori.compact<-LLSimpute(total.data$df.all,total.data$df.ori,total.data$n.changed)

     ##Imputing the too bad missing values
     ori.compact<-FinalImpute(ori.compact)

     ##Prepare readily used complete database for constructing Bayesian network
     bn.data<-PrepareCompData(ori.compact)
     n.microarray<-dim(ori.compact)[2]

     ##Do Bayesian network construction
     ##select a subset genes to be modeled
     selected.gene<-c(10:15)
     bn.data<-bn.data[1:(n.microarray-1),selected.gene]
     nw<-network(bn.data)

     ##specify a prior network
     nw.prior<-jointprior(nw,20)
     nw<-getnetwork(learn(nw,bn.data,nw.prior))

     ##perform greedy search
     nw.search<-autosearchEx(nw,bn.data,nw.prior,removecycles=TRUE)

     ##perturb initial network nw with random restarts to avoid local maximum
     nw.heu<-heuristicEx(getnetwork(nw.search),bn.data,nw.prior,removecycles=TRUE,restart=2,degree=10,trylist=gettrylist(nw.search))

     ##highest score network
     nw.best<-getnetwork(nw.heu)
     plot(nw.best,cexscale=3,unitscale=5)
     ## End(Not run)

