rnormDag                 package:ggm                 R Documentation

_R_a_n_d_o_m _s_a_m_p_l_e _f_r_o_m _a _d_e_c_o_m_p_o_s_a_b_l_e _G_a_u_s_s_i_a_n _m_o_d_e_l

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

     Generates a sample from a mean centered  multivariate normal
     distribution whose covariance matrix has a given triangular
     decomposition.

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

     rnormDag(n, A, Delta)

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

       n: an integer > 0, the sample size.

       A: a square, upper triangular matrix with ones along the
          diagonal. It defines, together with 'Delta', the
          concentration matrix (and also the covariance matrix) of the
          multivariate normal. The order of 'A' is the number of
          components of the normal.

   Delta: a numeric vector of length equal to the number of columns of
          'A'.

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

     The value in position (i,j) of  'A' (with i < j) is a regression
     coefficient (with  sign changed) in the regression of variable i
     on variables i+1, ..., d.

     The value in position i of 'Delta' is the residual variance in the
     above regression.

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

     a matrix with 'n' rows and 'nrow(A)' columns, a sample from a
     multivariate normal distribution with mean zero and covariance
     matrix 'S = solve(A) %*% diag(Delta) %*% t(solve(A))'.

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

     Giovanni M. Marchetti

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

     Cox, D. R. & Wermuth, N. (1996). _Multivariate dependencies_.
     London: Chapman & Hall.

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

     'triDec', 'fitDag'

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

     ## Generate a sample of 100 observation from a multivariate normal
     ## The matrix of the path coefficients 
     A <- matrix(
     c(1, -2, -3,  0, 0,  0,  0,
       0,  1,  0, -4, 0,  0,  0,
       0,  0,  1,  2, 0,  0,  0,
       0,  0,  0,  1, 1, -5,  0,
       0,  0,  0,  0, 1,  0,  3,
       0,  0,  0,  0, 0,  1, -4,
       0,  0,  0,  0, 0,  0,  1), 7, 7, byrow=TRUE)
     D <- rep(1, 7)
     X <- rnormDag(100, A, D)

     ## The true covariance matrix
     solve(A) %*% diag(D) %*% t(solve(A))

     ## Triangular decomposition of the sample covariance matrix
     triDec(cov(X))$A

