BWishart               package:Baldur               R Documentation

_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:

     'BWishart' produces iid draws from the Wishart Density.

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

      BWishart(draws,A0,n0)

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

   draws: Number of desired draws from the density 

      A0: n*n Scale Matrix

      n0: degree of Freedom parameter

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

     Produces iid draws from the Wishart density. The expected value of
     the density is given by A0*n0. The expected value for the inverse
     density is given by $(A0^(-1))/(n0-k-1)$, where k is the dimension
     of the density.

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

     An array of dimension  n*n*draws with iid draws from the Wishart
     density, where the last dimension is the index for the draws.

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

     Kjell Nygren knygren@us.imshealth.com

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

     ### Wishart Example 

     # Set Constants

     n0<-20
     A<-(0.5+diag(4)+matrix(0.5,4,4))/n0

     # Set Number of draws

     draws<-1000

     # Simulate 10,000 draws 

     system.time(out<-BWishart(draws,A,n0))

     # Calculate and display means from draws and "known" expectation

     outmean<-matrix(0,4,4)

     for(i in 1:4){
        for(j in 1:4){
             outmean[i,j]<-mean(out[i,j,1:draws])
                     }       
                  }

     outmean
     A*n0

     # Calculate Inverse Wishart

     outvar<-array(0,c(4,4,draws))

     for(k in 1:draws){
             for(i in 1:4){
                for(j in 1:4){
                     outvar[1:4,1:4,k]<-solve(out[1:4,1:4,k])
                             }       
                          }
                      }

     # Calculate mean, and display simulated and actual mean

     outmean2<-matrix(0,4,4)

     for(i in 1:4){
        for(j in 1:4){
             outmean2[i,j]<-mean(outvar[i,j,1:draws])
                     }       
                  }

     outmean2

     solve(A)/(n0-4-1)

