BayesFactor             package:MCMCpack             R Documentation

_C_r_e_a_t_e _a_n _o_b_j_e_c_t _o_f _c_l_a_s_s _B_a_y_e_s_F_a_c_t_o_r _f_r_o_m _M_C_M_C_p_a_c_k _o_u_t_p_u_t

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

     This function creates an object of class 'BayesFactor' from
     MCMCpack output.

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

     BayesFactor(...)
     is.BayesFactor(BF)

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

     ...: MCMCpack output objects. These have to be of class 'mcmc' and
          have a 'logmarglike' attribute. In what follows, we let 'M'
          denote the total number of models to be compared.

      BF: An object to be checked for membership in class
          'BayesFactor'.

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

     An object of class 'BayesFactor'. A 'BayesFactor' object has four
     attributes. They are: 'BF.mat' an M by M matrix in which element
     i,j contains the Bayes factor for model i relative to model j;
     'BF.log.mat' an M by M matrix in which element i,j contains the
     natural log of the Bayes factor for model i relative to model j;
     'BF.logmarglike' an M vector containing the log marginal
     likelihoods for models 1 through M; and 'BF.call' an M element
     list containing the calls used to fit  models 1 through M.

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

     'MCMCregress'

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

     ## Not run: 
     data(birthwt)

     model1 <- MCMCregress(bwt~age+lwt+as.factor(race) + smoke + ht,
                          data=birthwt, b0=c(2700, 0, 0, -500, -500,
                                             -500, -500),
                          B0=c(1e-6, .01, .01, 1.6e-5, 1.6e-5, 1.6e-5,
                               1.6e-5), c0=10, d0=4500000,
                          marginal.likelihood="Chib95", mcmc=10000)
      
     model2 <- MCMCregress(bwt~age+lwt+as.factor(race) + smoke,
                          data=birthwt, b0=c(2700, 0, 0, -500, -500,
                                             -500),
                          B0=c(1e-6, .01, .01, 1.6e-5, 1.6e-5, 1.6e-5),
                          c0=10, d0=4500000,
                          marginal.likelihood="Chib95", mcmc=10000)

     model3 <- MCMCregress(bwt~as.factor(race) + smoke + ht,
                          data=birthwt, b0=c(2700, -500, -500,
                                             -500, -500),
                          B0=c(1e-6, 1.6e-5, 1.6e-5, 1.6e-5,
                               1.6e-5), c0=10, d0=4500000,
                          marginal.likelihood="Chib95", mcmc=10000)

     BF <- BayesFactor(model1, model2, model3)
     print(BF)

     ## End(Not run)

