getBF | R Documentation |
Extract a path (log) Bayes factors (BFs) from the log marginal posterior
probabilities of two "dynaTree"
-class objects
getBF(obj1, obj2)
obj1 |
a |
obj2 |
another |
Simply calculates a difference in log marginal posterior
probabilities, setting BFs to zero for initial elements of the
path where one of the objects has more zero marginal probabilities
than the other. The BF is for the model in obj1
over
obj2
. If the objects are the output of repeated
fits as obtained from dynaTrees
, then multiple
traces are returned
Returns a vector or matrix
of a trace(s) of Bayes factors that
can be plotted; see examples below
Robert B. Gramacy rbg@vt.edu,
Matt Taddy and Christoforos Anagnostopoulos
Taddy, M.A., Gramacy, R.B., and Polson, N. (2011). “Dynamic trees for learning and design” Journal of the American Statistical Association, 106(493), pp. 109-123; arXiv:0912.1586
Gramacy, R.B., Taddy, M.A., and S. Wild (2011). “Variable Selection and Sensitivity Analysis via Dynamic Trees with an Application to Computer Code Performance Tuning” arXiv:1108.4739
https://bobby.gramacy.com/r_packages/dynaTree/
dynaTree
, update.dynaTree
,
link{logpost}
## parabola data
n <- 100
Xp <- sort(runif(n,-3,3))
Yp <- Xp + Xp^2 + rnorm(n, 0, .2)
XXp <- seq(-3,3,length=100)
## comparison by log Bayes Factor
R <- 2 ## use R >= 10 for better results
## small R is for faster CRAN checks
o <- apply(matrix(runif(n*(R-1)), ncol=R-1), 2, order)
lpc.p <- dynaTrees(Xp, Yp, R=R, rorder=o, verb=0)
lpl.p <- dynaTrees(Xp, Yp, model="linear", R=R, rorder=o, verb=0)
bf.p <- getBF(lpl.p, lpc.p)
## plot the log Bayes factors
matplot(bf.p, type="l", lty=1, col="gray", main="parabola",
xlab="time", ylab="log Bayes factor")
## see demo("reg1d") for further examples
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.