DAG                   package:ggm                   R Documentation

_D_i_r_e_c_t_e_d _a_c_y_c_l_i_c _g_r_a_p_h_s (_D_A_G_s)

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

     A simple way to define a DAG by means of regression model
     formulae.

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

     DAG(..., order = FALSE)

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

     ...: a sequence of model formulae

   order: logical, defaulting to 'FALSE'. If 'TRUE' the nodes of the
          DAG are permuted according to the topological order. If
          'FALSE' the nodes are in the order they first appear in the
          model formulae (from left to right).

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

     The DAG is defined by a sequence of recursive regression models.
     Each regression is defined by a model formula. For each formula
     the response defines a node of the graph and the explanatory
     variables the parents of that node. If the regressions are not
     recursive the function returns an error message.

     Some authors prefer the terminology acyclic directed graphs (ADG).

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

     the adjacency matrix of the DAG, i.e.  a square Boolean matrix of
     order equal to the number of nodes of the graph and a one in
     position (i,j) if there is an arrow from i to j and zero
     otherwise.  The rownames of the adjacency matrix are the nodes of
     the DAG. 

     If 'order = TRUE' the adjacency matrix is permuted to have 
     parents before  children. This can always be done (in more than
     one way) for DAGs. The resulting adjacency matrix is upper
     triangular.

_N_o_t_e:

     The model formulae may contain interactions, but they are ignored
     in the graph.

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

     G. M. Marchetti

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

     Lauritzen, S. (1996). _Graphical models_. Oxford: Clarendon Press.

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

     'UG', 'topSort', 'edgeMatrix', 'fitDag'

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

     ## A Markov chain
     DAG(y ~ x, x ~ z, z ~ u)

     ## Another DAG
     DAG(y ~ x + z + u, x ~ u, z ~ u)

     ## A DAG with an isolated node
     DAG(v ~ v, y ~ x + z, z ~ w + u)

     ## There can be repetitions
     DAG(y ~ x + u + v, y ~ z, u ~ v + z)

     ## Interactions are ignored
     DAG(y ~ x*z + z*v, x ~ z)

     ## A cyclic graph returns an error!
     ## Not run: DAG(y ~ x, x ~ z, z ~ y)

     ## The order can be changed
     DAG(y ~ z, y ~ x + u + v,  u ~ v + z)

     ## If you want to order the nodes (topological sort of the DAG)
     DAG(y ~ z, y ~ x + u + v,  u ~ v + z, order=TRUE)

