Mvnorm                package:mvtnorm                R Documentation

_M_u_l_t_i_v_a_r_i_a_t_e _N_o_r_m_a_l _D_e_n_s_i_t_y _a_n_d _R_a_n_d_o_m _N_u_m_b_e_r_s

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

     These functions provide the density function and a random number
     generator for the multivariate normal distribution with mean equal
     to 'mean' and covariance matrix 'sigma'.

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

     dmvnorm(x, mean, sigma, log=FALSE)
     rmvnorm(n, mean, sigma, method=c("svd", "chol"))

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

       x: Vector or matrix of quantiles. If 'x' is a matrix, each row
          is taken to be a quantile.

       n: Number of observations.

    mean: Mean vector, default is 'rep(0, length = ncol(x))'.

   sigma: Covariance matrix, default is 'diag(ncol(x))'.

     log: Logical; if 'TRUE', densities d are given as log(d).

  method: Matrix decomposition used to determine the matrix root of
          'sigma', possible methods are singular value decomposition
          ('"svd"', default) and Cholesky decomposition ('"chol"').

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

     SVD will work even for numerically negative definite 'sigma' (with
     a warning), while the Cholesky decomposition is possible only for
     non-negative  definite 'sigma' and issues a warning for positive
     semi-definiteness. Using 'method = "chol"' may be faster and more
     stable for higher dimensional 'sigma'.

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

     Friedrich Leisch <Friedrich.Leisch@R-project.org>, Fabian Scheipl

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

     'pmvnorm', 'rnorm', 'qmvnorm'

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

     dmvnorm(x=c(0,0))
     dmvnorm(x=c(0,0), mean=c(1,1))

     sigma <- matrix(c(4,2,2,3), ncol=2)
     x <- rmvnorm(n=500, mean=c(1,2), sigma=sigma)
     colMeans(x)
     var(x)

     x <- rmvnorm(n=500, mean=c(1,2), sigma=sigma, method="chol")
     colMeans(x)
     var(x)

     plot(x)

