Description Usage Arguments Value Author(s) Examples
Get posterior samples from the Bayesian Model Average (BMA)
1 2 | getBmaSamples(config, logPostProbs, nSamples, modelData,
mcmc = getMcmc(), computation = getComputation())
|
config |
the data frame/matrix with model
specifications, e.g. the result from
|
logPostProbs |
vector of log posterior probabilites
(will be exponentiated and normalized within the
function) for the weighting of the models in
|
nSamples |
number of samples to simulate |
modelData |
the data necessary for model estimation,
which is the result from |
mcmc |
MCMC options produced by
|
computation |
computation options produced by
|
A list with samples from the shrinkage hyperparameter,
the regression variance, and the (linear and spline)
coefficients, analogous to the return value from
getSamples
or glmGetSamples
.
The only difference is that “linearCoefs” and
“splineCoefs” contain zeroes for samples where the
model did not contain that covariate linearly or
smoothly. This is necessary to ensure compatibility with
getFunctionSamples
and
getFitSamples
. Moreover, the model
specifications matrix is appended with columns
“postProb” and “sampleFreq”, containing the
posterior probability and the sampling frequency,
respectively.
Daniel Sabanes Bove daniel.sabanesbove@ifspm.uzh.ch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | ## get some data
attach(longley)
## get model data
md <- modelData(y=Employed,
X=cbind(GNP, Armed.Forces),
gPrior="hyper-g/n")
## get models table
tab <- exhaustive(modelData=md)$models
tab
## get posterior samples from the BMA assuming
## a flat model prior
res <- getBmaSamples(config=tab,
logPostProbs=tab$logMargLik,
nSamples=1000L,
modelData=md)
str(res)
summary(res$t)
hist(res$t, nclass=100)
## now for generalised response:
## get the model data
md <- glmModelData(y=as.numeric(Employed > 64),
X=cbind(GNP, Armed.Forces),
family=binomial)
## get models table
tab <- exhaustive(modelData=md,
computation=
getComputation(higherOrderCorrection=FALSE))$models
## get posterior samples from the BMA assuming
## a flat model prior
res <- getBmaSamples(config=tab,
logPostProbs=tab$logMargLik,
nSamples=1000L,
modelData=md,
mcmc=
getMcmc(burnin=10L,
step=1L),
computation=
getComputation(higherOrderCorrection=FALSE))
str(res)
hist(res$t, nclass=100)
res$config
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.