MCpoissongamma           package:MCMCpack           R Documentation

_M_o_n_t_e _C_a_r_l_o _S_i_m_u_l_a_t_i_o_n _f_r_o_m _a _P_o_i_s_s_o_n _L_i_k_e_l_i_h_o_o_d _w_i_t_h _a _G_a_m_m_a _P_r_i_o_r

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

     This function generates a sample from the posterior distribution
     of a Poisson likelihood with a Gamma prior.

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

     MCpoissongamma(y, alpha, beta, mc=1000, ...)

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

       y: A vector of counts (must be non-negative).

   alpha: Gamma prior distribution shape parameter.

    beta: Gamma prior distribution scale parameter.

      mc: The number of Monte Carlo draws to make.

     ...: further arguments to be passed

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

     'MCpoissongamma' directly simulates from the posterior
     distribution.  This model is designed primarily for instructional
     use.  lambda is the parameter of interest of the Poisson
     distribution. We assume a conjugate Gamma prior:

                     lambda ~ Gamma(alpha, beta)

     y is a vector of counts.

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

     An mcmc object that contains the posterior sample.  This  object
     can be summarized by functions provided by the coda package.

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

     'plot.mcmc', 'summary.mcmc'

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

     ## Not run: 
     data(quine)
     posterior <- MCpoissongamma(quine$Days, 15, 1, 5000)
     summary(posterior)
     plot(posterior)
     grid <- seq(14,18,0.01)
     plot(grid, dgamma(grid, 15, 1), type="l", col="red", lwd=3, ylim=c(0,1.3),
       xlab="lambda", ylab="density")
     lines(density(posterior), col="blue", lwd=3)
     legend(17, 1.3, c("prior", "posterior"), lwd=3, col=c("red", "blue"))
     ## End(Not run)

