pmpmodel: Posterior Model Probability for any Model

View source: R/aux_outer.R

pmpmodelR Documentation

Posterior Model Probability for any Model

Description

Returns the posterior model probability for any model based on bma results

Usage

pmpmodel(bmao, model = numeric(0), exact = TRUE)

Arguments

bmao

A bma object as created by bms.

model

A model index - either variable names, or a logical with model binaries, or the model hexcode (cf. hex2bin, or a numeric with positions of the variables to be included.

exact

If TRUE, then the resulting PMP is based on analytical model likelihoods (works for any model).
If FALSE, the the resulting PMP is derived from MCMC frequencies (works only for the null and fullmodel, as well as for models contained in bmao's topmod object.
If bmao is based on enumeration (cf. argument mcmc in bms, then exact does not matter.

Details

If the model as provided in model is the null or the full model, or is contained in bmao's topmod object (cf. argument nmodel in bms),
then the result is the same as in pmp.bma.
If not and exact=TRUE, then pmpmodel estimates the model based on comparing its marginal likelihood (times model prior) to the likelihoods in the topmod object and multiplying by their sum of PMP according to MCMC frequencies,

Value

A scalar with (an estimate of) the posterior model probability for model

See Also

pmp.bma for similar functions

Check http://bms.zeugner.eu for additional help.

Examples



## sample BMA for growth dataset, enumeration sampler
data(datafls)
mm=bms(datafls[,1:10],nmodel=5)

#show the best 5 models:
pmp.bma(mm)
#first column: posterior model prob based on model likelihoods,
#second column: posterior model prob based MCMC frequencies,

### Different ways to get the same result: #########

#PMP of 2nd-best model (hex-code representation)
pmpmodel(mm,"00c")

#PMP of 2nd-best model (binary representation)
incls=as.logical(beta.draws.bma(mm)[,2])
pmpmodel(mm,incls)

#PMP of 2nd-best model (via variable names)
#names of regressors in model "00c": 
names(datafls[,2:10])[incls]
pmpmodel(mm,c("SubSahara", "LatAmerica"))

#PMP of 2nd-best model (via positions)
pmpmodel(mm,c(6,7))

####PMP of another model #########
pmpmodel(mm,1:5)



BMS documentation built on Aug. 9, 2022, 5:08 p.m.