randmvn               package:monomvn               R Documentation

_R_a_n_d_o_m_l_y _G_e_n_e_r_a_t_e _a _M_u_l_t_i_v_a_r_i_a_t_e _N_o_r_m_a_l _D_i_s_t_r_i_b_u_t_i_o_n

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

     Randomly generate a mean vector and covariance matrix describing a
     multivariate normal (MVN) distribution, and then sample from it

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

     randmvn(N, d, method = c("normwish", "parsimonious"),
             mup=list(mu = 0, s2 = 1), s2p=list(a = 0.5, b = 1),
             pnz=0.1, nu=Inf)

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

       N: number of samples to draw 

       d: dimension of the  MVN, i.e., the length of the mean vector
          and the number of rows/cols of the covariance matrix 

  method: the default generation method is '"norwish"' uses the direct
          method described in the details section below, whereas the
          '"parsimonious"' method builds up the random mean vector and
          covariance via regression coefficients, intercepts, and
          variances. See below for more details.  Here, a random number
          of regression coefficients for each regression are set to
          zero 

     mup: a 'list' with entries '$mu' and '$s2': '$mu' is the prior
          mean for the independent components of the normally
          distributed mean vector; '$s2' is the prior variance

     s2p: a 'list' with entries '$a' and '$b'  only valid for 'method =
          "parsimonious"': '$a > 0' is the baseline inverse gamma prior
          scale parameter for the regression variances (the actual
          parameter used for each column 'i in 1:d' of the covariance
          matrix is 'a + i - 1'); '$b >= 0' is the rate parameter

     pnz: a scalar '0 <= pnz <= 1', only valid for 'method =
          "parsimonious"': determines the binomial proportion of
          non-zero regression coefficients in the sequential build-up
          of 'mu' and 'S', thereby indirectly determining the number of
          non-zero entries in 'S'

      nu: a scalar '>= 1' indicating the degrees of freedom of a
          Student-t distribution to be used instead of an MVN when not
          infinite 

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

     In the direct method ('"normwish"') the components of the mean
     vector 'mu' are iid from a standard normal distribution, and the
     covariance matrix 'S' is drawn from an inverse-Wishart
     distribution with degrees of freedom 'd + 2' and mean (centering
     matrix) 'diag(d)'

     In the '"parsimonious"' method 'mu' and 'S' are built up
     sequentially by randomly sampling intercepts, regression
     coefficients (of length 'i-1' for 'i in 1:d') and variances by
     applying the 'monomvn' equations.  A unique prior results when a
     random number of the regression coefficients are set to zero. When
     none are set to zero the direct method results

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

     The return value is a 'list' with the following components: 

     mu : randomly generated mean vector of length 'd' 

      S : randomly generated covariance 'matrix' with 'd' rows and 'd'
          columns 

      x : if 'N > 0' then 'x' is an 'N*d' 'matrix' of 'N' samples from
          the MVN with mean vector 'mu' and covariance 'matrix' 'S';
          otherwise when 'N = 0' this component is not included

_N_o_t_e:

     requires the 'rmvnorm' function of the 'mvtnorm' package

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

     Robert B. Gramacy bobby@statslab.cam.ac.uk

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

     'rwish', 'rmvnorm', 'rmono'

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

     randmvn(5, 3)

