learn                  package:deal                  R Documentation

_E_s_t_i_m_a_t_i_o_n _o_f _p_a_r_a_m_e_t_e_r_s _i_n _t_h_e _l_o_c_a_l _p_r_o_b_a_b_i_l_i_t_y
_d_i_s_t_r_i_b_u_t_i_o_n_s

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

     Updates the distributions of the parameters in the network, based
     on a prior network and data. Also, the network score is
     calculated.

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

     learn (nw, df, prior=jointprior(nw),
                    nodelist=1:size(nw),
                    trylist=vector("list",size(nw)),
                    timetrace=FALSE) 

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

      nw: an object of class 'network'.

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

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

nodelist: a numeric vector of indices of nodes to be learned.

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

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

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

     The procedure 'learn' determines the master prior, local parameter
     priors and local parameter posteriors, see Bttcher (2001). It may
     be called on all nodes (default) or just a single node. 

     From the joint prior distribution, the marginal distribution of
     all parameters in the family consisting of the node and its
     parents can be determined. This is the master prior, see
     'localmaster'.

     The local parameter priors are now determined by conditioning in
     the master prior distribution, see 'conditional'. The
     hyperparameters associated with the local parameter prior
     distribution is attached to each node in the property 'condprior'.

     Finally, the local parameter posterior distributions are
     calculated (see 'post') and attached to each node in the property
     'condposterior'. 

     A so-called trylist is maintained to speedup the learning process.
     The trylist consists of a list of matrices for each node. The
     matrix for a given node holds previously evaluated parent
     configurations and the corresponding log-likelihood contribution.
     If a node with a certain parent configuration needs to be learned,
     it is checked, whether the node has already been learned. The
     previously learned nodes are given as input in the trylist
     parameter and is updated in the learning procedure. 

     When one or more nodes in a network have been learned, the network
     score is updated and attached to the network in the property
     'score'.  

     The learning procedure is called from various functions using the
     principle, that networks should always be updated with their
     score. Thus, e.g. 'drawnetwork' keeps the network updated when the
     graph is altered.

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

     A list with two elements that may be accessed using 'getnetwork'
     and 'gettrylist'. The elements are 

      nw: an object of class 'network', with the 'condposterior'
          properties updated for  the nodes. Also, the property 'score'
          is updated and contains the network score. The contribution
          to the network score for each node is contained in the
          property 'loglik' for each node.

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

_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:

     Bttcher, S.G. (2001). Learning Bayesian Networks with Mixed
     Variables, {\em Artificial Intelligence and Statistics 2001},
     Morgan Kaufmann, San Francisco, CA, USA, 149-156.

     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', 'jointprior', 'maketrylist', 'network'

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

     data(rats)
     fit       <- network(rats)
     fit.prior <- jointprior(fit,12)
     fit.learn <- learn(fit,rats,fit.prior,timetrace=TRUE)
     fit.nw    <- getnetwork(fit.learn)
     fit.learn2<- learn(fit,rats,fit.prior,trylist=gettrylist(fit.learn),timetrace=TRUE)

