bayesDensity: Bayesian kernel density estimation

Description Usage Arguments References Examples

View source: R/bayesDensity.R

Description

Bayesian kernel density estimation

Usage

1
2
bayesDensity(x, bw = bw.nrd(x), m = 512, nsim = 5000, n = 512,
  alpha = 0.95, na.rm = TRUE)

Arguments

x

numeric vector.

bw

the smoothing bandwidth to be used.

m

size of the grid used for calculating density.

nsim

number of simulated draws.

n

the number of equally spaced points at which the density is to be estimated.

alpha

confidence level of the interval.

na.rm

logical; if TRUE, missing values are removed from x. If FALSE any missing values cause an error.

References

Sibisi, S., & Skilling, J. (1996). Bayesian Density Estimation. In Maximum Entropy and Bayesian Methods (pp. 189-198). Springer.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
x <- c(rnorm(150, 20), rnorm(200, 15))

(fit <- bayesDensity(x))
plot(fit)
lines(density(x), col = "red", lty = 2)
rug(x, lwd = 2)

x <- mtcars$mpg

plot(bayesDensity(x))
lines(density(x), col = "red", lty = 2)
rug(x, lwd = 2)

twolodzko/twextras documentation built on May 3, 2019, 1:52 p.m.