R: Area of the posterior density in the ROPE as a function of...
plotAreaInROPE
R Documentation
Area of the posterior density in the ROPE as a function of its width.
Description
Calculates and (optionally) plots the posterior probability mass included in the Region of Practical Equivalence (ROPE: see plot.BEST) as a function of the width of the ROPE.
A vector of samples drawn from the target distribution; see Examples.
credMass
The probability mass to include in credible intervals.
compVal
a value for comparison with those plotted.
maxROPEradius
The maximum value of the ROPE radius (ie. half-width) to include in the plot.
n
The number of equally spaced points at which the area in the ROPE is to be estimated.
plot
If FALSE, the plot will be suppressed but the values will be returned.
...
Other graphical parameters.
Details
Defining a Region of Practical Equivalence (ROPE) allows decisions on whether a parameter is, for practical purposes, equivalent to a hypothetical null value, given a posterior probability density for the parameter. The null value may be considered credible if (A) 95% (say) of the probability mass lies within the ROPE, or (B) the 95% highest density interval (95% HDI) lies entirely within the ROPE.
How wide should the ROPE be? Different people at different times will have different ideas on the range of values equivalent to the null. The function plotAreaInROPE plots the probability mass lying within the ROPE for a range of widths (or rather radii or half-widths). It also shows the radius at which the HDI falls entirely within the ROPE.
Value
Returns invisibly a list with elements:
x
A vector of ROPE radii from 0 to maxROPEradius.
y
The corresponding proportion of the posterior density included in the ROPE.
Author(s)
John K. Kruschke, with minor modifications by Mike Meredith.
# Generate a fake MCMC posterior for effect size and plot it:
mcmcChain <- rnorm(50000,0.03,0.025)
plotPost(mcmcChain, compVal=0, ROPE=c(-0.1, 0.1))
# How does the mass within the ROPE vary with ROPE radius?
plotAreaInROPE(mcmcChain, credMass = 0.95, compVal = 0,
maxROPEradius = 0.15)
# Generate real MCMC chains, takes up to 1 min:
y1 <- c(4.77, 4.33, 3.59, 3.33, 2.66, 3.48)
y2 <- c(3.88, 3.55, 3.29, 2.59, 2.33, 3.59)
BESTout <- BESTmcmc(y1, y2)
plot(BESTout)
meanDiff <- BESTout$mu1 - BESTout$mu2
plotAreaInROPE(meanDiff, credMass = 0.95, compVal = 0,
maxROPEradius = 3)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(BEST)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/BEST/plotAreaInROPE.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plotAreaInROPE
> ### Title: Area of the posterior density in the ROPE as a function of its
> ### width.
> ### Aliases: plotAreaInROPE
> ### Keywords: hplot
>
> ### ** Examples
>
> # Generate a fake MCMC posterior for effect size and plot it:
> mcmcChain <- rnorm(50000,0.03,0.025)
> plotPost(mcmcChain, compVal=0, ROPE=c(-0.1, 0.1))
>
> # How does the mass within the ROPE vary with ROPE radius?
> plotAreaInROPE(mcmcChain, credMass = 0.95, compVal = 0,
+ maxROPEradius = 0.15)
>
> ## No test:
> # Generate real MCMC chains, takes up to 1 min:
> y1 <- c(4.77, 4.33, 3.59, 3.33, 2.66, 3.48)
> y2 <- c(3.88, 3.55, 3.29, 2.59, 2.33, 3.59)
> BESTout <- BESTmcmc(y1, y2)
Processing function input.......
Done.
Beginning parallel processing using 3 cores. Console output will be suppressed.
Parallel processing completed.
MCMC took 0.107 minutes.
> plot(BESTout)
>
> meanDiff <- BESTout$mu1 - BESTout$mu2
> plotAreaInROPE(meanDiff, credMass = 0.95, compVal = 0,
+ maxROPEradius = 3)
> ## End(No test)
>
>
>
>
>
> dev.off()
null device
1
>