hpd: Computing Highest Posterior Density (HPD) Intervals

Description Usage Arguments Details Author(s) Examples

View source: R/hpd.R

Description

Compute approximate HPD intervals out of MCMC-samples in BayesX

Usage

1
2
hpd(data, alpha = 0.05, ...)
hpd.coda(data, alpha = 0.05)

Arguments

data

Either the name of a file or a data frame containing the sample.

alpha

A numeric scalar in the interval (0,1) such that 1 - alpha is the target probability content of the intervals.. The default is alpha = 0.05.

...

Further parameters to be passed to the internal call of optim and integrate.

Details

hpd computes the HPD interval based on a kernel density estimate of the samples. hpd.coda computes the HPD interval with the function HPDinterval available in package coda.

Author(s)

Nadja Klein

Examples

1
2
3
4
res <- read.table(system.file("examples/nonparametric_f_x_pspline_sample.raw",
  package="BayesX"), header = TRUE)
hpd(res)
hpd.coda(res)

Example output

Loading required package: shapefiles
Loading required package: foreign

Attaching package: 'shapefiles'

The following objects are masked from 'package:foreign':

    read.dbf, write.dbf

Note: Function plotsurf depends on akima which has
 a restricted licence that explicitly forbids commercial use.
 akima is therefore disabled by default and may be enabled by
 akimaPermit(). Calling this function includes your agreement to
 akima`s licence restrictions.
         lower       upper
1  -0.33966495  0.69718137
2  -0.30897372  0.12420943
3  -0.47152485 -0.22708400
4  -0.76149958 -0.49035710
5  -1.01126031 -0.72331632
6  -1.15123550 -0.88292009
7  -1.15542899 -0.89803824
8  -1.05186076 -0.77631826
9  -0.87869891 -0.61360062
10 -0.66569402 -0.38174919
11 -0.31705368 -0.05199864
12  0.05752371  0.29275952
13  0.32851136  0.58301518
14  0.55936977  0.84869620
15  0.79847074  1.04814047
16  0.94121948  1.18377916
17  0.93497981  1.19556850
18  0.74554313  1.03075079
19  0.53780372  0.80403190
20  0.23126123  0.47822812
21 -0.24344184  0.22413135
22 -0.93178732  0.15521436
           lower      upper
var1  -0.3737270  0.6470020
var2  -0.3010350  0.1192700
var3  -0.4651320 -0.2267850
var4  -0.7499560 -0.4862650
var5  -1.0131600 -0.7370940
var6  -1.1464500 -0.8866780
var7  -1.1528300 -0.9045740
var8  -1.0416400 -0.7713750
var9  -0.8789530 -0.6211370
var10 -0.6617710 -0.3902920
var11 -0.3133670 -0.0591118
var12  0.0608454  0.2915230
var13  0.3247550  0.5714290
var14  0.5691100  0.8487950
var15  0.8030410  1.0425600
var16  0.9517270  1.1878700
var17  0.9343180  1.1852900
var18  0.7489040  1.0213500
var19  0.5466470  0.8019260
var20  0.2290470  0.4689380
var21 -0.2383810  0.2143830
var22 -0.8875630  0.1511010

BayesX documentation built on Aug. 24, 2019, 9:03 a.m.