mod_probs: Compute Posterior Model Probabilities

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/mod_probs.R

Description

This function computes the posterior model probabilities using the MCMC output of "bcct" and "bict" objects.

Usage

1
mod_probs(object, n.burnin = 0, scale = 0.1, best = NULL, thin = 1)

Arguments

object

An object of class "bcct" or "bict".

n.burnin

An optional argument giving the number of iterations to use as burn-in. The default value is 0.

scale

An optional argument for controlling how the posterior model probabilities are returned as output. The function will return details on the models with the posterior model probability larger than scale times the probability of the posterior modal model. The default value is 0.1.

best

An optional argument for controlling how the posterior model probabilities are returned as output. The function will return details on the best models with the highest posterior model probabilities. For example, if best=4, then details on the four models with the highest posterior model probabilities will be returned. The default value is NULL. If not NULL, then this argument takes precedent over scale.

thin

An optional argument giving the amount of thinning to use, i.e. the computations are based on every thin-th value in the MCMC sample. The default value is 1, i.e. no thinning.

Details

It will output only the probabilities of the "best" models, as defined by the user specifying either the best or scale arguments.

The use of thinning is recommended when the number of MCMC iterations and/or the number of log-linear parameters in the maximal model are/is large, which may cause problems with comuter memory storage.

Value

The function will return an object of class "modprobs" which is a list containing the following components.

table

An object of class "data.frame" with number of rows defined by scale or best and columns: model_formula; giving the model (in terms of a printed formula), and prob; giving the posterior model probability.

totmodsvisit

A numeric scalar giving the total number of models visited after the burn-in iterations.

Author(s)

Antony M. Overstall A.M.Overstall@soton.ac.uk.

See Also

bcct, bict, print.modprobs.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
set.seed(1)
## Set seed for reproducibility
data(AOH)
## Load AOH data

test1<-bcct(formula=y~(alc+hyp+obe)^3,data=AOH,n.sample=100,prior="UIP")
## Starting from maximal model of saturated model do 100 iterations of MCMC
## algorithm.

mod_probs(object=test1,n.burnin=10,best=6)
## Using a burn-in of 10 iterations find the posterior model probabilities 
## of the 6 models with the highest posterior model probability. Will get:

#Posterior model probabilities:
#  prob    model_formula                       
#1 0.50000 ~alc + hyp + obe                    
#2 0.32222 ~alc + hyp + obe + hyp:obe          
#3 0.12222 ~alc + hyp + obe + alc:hyp + hyp:obe
#4 0.05556 ~alc + hyp + obe + alc:hyp          
#
#Total number of models visited =  4

## Note that since the chain only visited 4 models we only get probabilities
## for 4 models not 6.

conting documentation built on May 1, 2019, 8:47 p.m.