hpd              package:TeachingDemos              R Documentation

_C_o_m_p_u_t_e _H_i_g_h_e_s_t _P_o_s_t_e_r_i_o_r _D_e_n_s_i_t_y _I_n_t_e_r_v_a_l_s

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

     Compute the Highest Posterior Density Interval (HPD) from an
     inverse density function (hpd) or a vector of realizations of the
     distribution (emp.hpd).

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

     hpd(posterior.icdf, conf=0.95, tol=0.00000001,...)

     emp.hpd(x, conf=0.95)

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

posterior.icdf: Function, the inverse cdf of the posterior distribution
          (usually a function whose name starts with 'q').

       x: A vector of realizations from the posterior distribution.

    conf: Scalar, the confidence level desired. 

     tol: Scalar, the tolerance for 'optimize'.

     ...: Additional arguments to 'posterior.icdf'.

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

     These functions compute the highest posterior density intervals
     (sometimes called minimum length confidence intervals) for a
     Bayesian posterior distribution.  The 'hpd' function is used when
     you have a function representing the inverse cdf (the common case
     with conjugate families).  The 'emp.hpd' function is used when you
     have realizations of the posterior (when you have results from an
     MCMC run).

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

     A vector of length 2 with the lower and upper limits of the
     interval.

_N_o_t_e:

     These functions assume that the posterior distribution is
     unimodal, they compute only 1 interval, not the set of intervals
     that are appropriate for multimodal distributions.

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

     Greg Snow greg.snow@intermountainmail.org 

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

     'hdr' in the hdrcde package.

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

     hpd(qbeta, shape1=50, shape2=250)

     tmp <- rbeta(10000, 50, 250)
     emp.hpd(tmp)

