simcontour            package:LearnBayes            R Documentation

_S_i_m_u_l_a_t_e_d _d_r_a_w_s _f_r_o_m _a _b_i_v_a_r_i_a_t_e _d_e_n_s_i_t_y _f_u_n_c_t_i_o_n _o_n _a _g_r_i_d

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

     For a general two parameter density defined on a grid, simulates a
     random sample.

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

     simcontour(logf,limits,data,m)

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

    logf: function that defines the logarithm of the  density

  limits: limits (xlo, xhi, ylo, yhi) that cover the joint probability
          density

    data: vector or list of parameters associated with the function
          logpost

       m: size of simulated sample

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

       x: vector of simulated draws of the first parameter

       y: vector of simulated draws of the second parameter

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

     Jim Albert

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

     lbinorm=function(xy,par)
     {
             m=par$m
             v=par$v
             x=xy[,1]
             y=xy[,2]
             zx=(x-m[1])/sqrt(v[1,1])
             zy=(y-m[2])/sqrt(v[2,2])
             r=v[1,2]/sqrt(v[1,1]*v[2,2])
             return(-.5/(1-r^2)*(zx^2-2*r*zx*zy+zy^2))
     }
     m=array(c(0,0),c(2,1))
     v=array(c(1,.6,.6,1),c(2,2))
     normpar=list(m=m,v=v)
     s=simcontour(lbinorm,c(-4,4,-4,4),normpar,1000)
     plot(s$x,s$y)

