rWishart              package:bayesSurv              R Documentation

_S_a_m_p_l_e _f_r_o_m _t_h_e _W_i_s_h_a_r_t _d_i_s_t_r_i_b_u_t_i_o_n

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

     Sample from the Wishart distribution

                           Wishart(nu, S),

     where nu are degrees of freedom of the Wishart distribution and S
     is its scale matrix. The same parametrization as in Gelman (2004)
     is assumed, that is, if W~Wishart(nu,S) then

                             E(W) = nu*S

     .

     In the univariate case, Wishart(nu,S) is the same as Gamma(nu/2,
     1/(2*S)).  

     Generation of random numbers is performed by the algorithm
     described in Ripley (1987, pp. 99).

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

     rWishart(n, df, S)

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

       n: number of observations to be sampled.

      df: degrees of freedom of the Wishart distribution. 

       S: scale matrix of the Wishart distribution. 

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

     Matrix with sampled points (lower triangles of W) in rows.

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

     Arno&#353t Kom&#225rek komarek@karlin.mff.cuni.cz

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

     Gelman, A., Carlin, J. B., Stern, H. S., and Rubin, D. B. (2004).
     _Bayesian Data Analysis, Second edition_.  Boca Raton: Chapman and
     Hall/CRC.

     Ripley, B. D. (1987). _Stochastic Simulation_. New York: John
     Wiley and Sons.

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

     ### The same as rgamma(n, shape=df/2, rate=1/(2*S))
     n <- 1000
     df <- 1
     S  <- 3
     w <- rWishart(n=n, df=df, S=S)
     mean(w)    ## should be close to df*S
     var(w)     ## should be close to 2*df*S^2

     ### Multivariate Wishart
     n <- 1000
     df <- 2
     S <- matrix(c(1,3,3,13), nrow=2)
     w <- rWishart(n=n, df=df, S=S)
     apply(w, 2, mean)                ## should be close to df*S
     df*S

     df <- 2.5
     S <- matrix(c(1,2,3,2,20,26,3,26,70), nrow=3)
     w <- rWishart(n=n, df=df, S=S)
     apply(w, 2, mean)                ## should be close to df*S
     df*S

