Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

BayesFactor

Create an object of class BayesFactor from MCMCpack output


Description

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

Usage

BayesFactor(...)

is.BayesFactor(BF)

Arguments

...

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.

Value

An object of class BayesFactor. A BayesFactor object has four attributes. They are: BF.mat an M \times M matrix in which element i,j contains the Bayes factor for model i relative to model j; BF.log.mat an M \times 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.

See Also

Examples

## 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)

MCMCpack

Markov Chain Monte Carlo (MCMC) Package

v1.5-0
GPL-3
Authors
Andrew D. Martin [aut], Kevin M. Quinn [aut], Jong Hee Park [aut,cre], Ghislain Vieilledent [ctb], Michael Malecki[ctb], Matthew Blackwell [ctb], Keith Poole [ctb], Craig Reed [ctb], Ben Goodrich [ctb], Ross Ihaka [cph], The R Development Core Team [cph], The R Foundation [cph], Pierre L'Ecuyer [cph], Makoto Matsumoto [cph], Takuji Nishimura [cph]
Initial release
2021-01-19

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.