visualizeBF: Function for exploring Bayes Factors.

Description Usage Arguments Value Examples

View source: R/visualizeBF_function.R

Description

Function for exploring Bayes Factors.

Usage

1
visualizeBF(data, pointsize = 0.001, scale = 0.707, plot = 1)

Arguments

data

A vector of data

pointsize

Width of points for numerical integration, defaults to .001.

scale

Scale parameter for Cauchy prior, defaults to .707

plot

The type of plot to produce. 1=BF as weighted likelihood, 2=BF as comparison of densities under prior and posterior at mu=0. for mu=0 under prior and posterior distributions.

Value

Returns a list with the following components:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
set.seed(1)
data <- rnorm(n=50, mean=.3, sd=1)
visualizeBF(data, plot=1)
visualizeBF(data, plot=2)

a <- visualizeBF(data, plot=1)

# extract density of the prior distribution at mu=0
a$prior.mu0

# calculate BF10 as likelihood ratio
a$L.m1 / a$L.m0

# alternative method for calculating BF10 as density ratio
a$prior.mu0 / a$posterior.mu0

# view the plot
a$figure

# restore plot defaults
dev.off()

mcbeem/visualizeBF documentation built on Nov. 19, 2019, 12:35 a.m.