ASH1D: Univariate density estimation for given observations

View source: R/z_ash.R

ASH1DR Documentation

Univariate density estimation for given observations

Description

Univariate density estimation for given observations

Usage

ASH1D(x, data = NULL, n = 200, k = 5, r = NULL, rx = 1.1, safe = TRUE, ...)

Arguments

x

numeric vector.

data

numeric vector (optional).

n

number of bins.

k

smoothing in number of bins.

rx

range expansion.

safe

logical (defautl = TRUE, yes).

...

optional argument (kopt) forwarded to the bin1 function.

Value

ASH1D returns a numeric vector with estimated densities.

See Also

ASH2D

Examples


## Not run: 

n1 <- 30000
n2 <- 60000
g <- c(rep(1, n1), rep(2, n2))
x <- c(rnorm(n1, 0, 1), rnorm(n2, 0, 5))

o <- order(x)
x <- x[o]
g <- g[o]

dt <- ASH1D(x, k = 5)
d1 <- ASH1D(x, data = x[g == 1], k = 10)
d2 <- ASH1D(x, data = x[g == 2], k = 10)

clr <- c(
  dt        = grey(0.0, 0.6),
  d1        = rgb(1.0, 0.5, 0.0, 0.6),
  d2        = rgb(0.0, 0.5, 1.0, 0.6),
  `d1 + d2` = rgb(1.0, 0.0, 0.0, 0.6)
)

EmptyPlot(xlim = range(x), ylim = range(dt, d1, d2, d1 + d2))
par(lwd = 1.5)
lines(x, d1 + d2, col = clr[4])
lines(x, dt, col = clr["dt"])
lines(x, d1, col = clr["d1"])
lines(x, d2, col = clr["d2"])
legend("topright", legend = names(clr), fill = clr, bty = "n")

## End(Not run)

benja0x40/Barbouille documentation built on March 26, 2023, 11:38 p.m.