Description Usage Arguments Value Author(s) See Also Examples
Make ADEBA density estimate
1 |
data |
Dataset with examples as rows and dimensions as columns, supplied as
a matrix or something that can be converted to a matrix, like a
|
adaptive |
Whether to used fixed bandwidths identical for all kernels, or adaptive bandwidths unique to each kernel. Can also be specified as a positive integer to iterate beyond the adaptive estimate (see the original publication). |
beta |
The level of adaptiveness. The default value of 0.5 corresponds to Silverman's square root law, which is suitable for the normal distribution. Can also be specified as multiple equispaced values, automatically weighted by the Bayesian machinery (the equispace requirement is for the integral approximation to hold). |
parallel |
Whether to use multiple CPU cores for calculation, using
|
na.rm |
Whether to let missing values break execution ( |
... |
Sent to the internal function |
A density estimate.
Christofer B<c3><a4>cklin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # Univariate
x.train <- c(rnorm(20, 0, .5), rnorm(20, 2, 2))
f <- adeba(x.train, beta = 0:2/2)
curve((dnorm(x, 0, .5) + dnorm(x, 2, 2))/2, -2, 7, lwd=5, col="grey85")
plot(f, type="both", add=TRUE)
points(f)
# Bi-variate
x.train <- 3 + sweep(matrix(rnorm(60), 30), 2, 1:2, "*") %*% matrix(c(1, .4, .4, 1), 2)
x.test <- 3 + sweep(matrix(rnorm(40), 20), 2, 1:2, "*") %*% matrix(c(1, .4, .4, 1), 2)
f <- adeba(x.train, adaptive=FALSE)
f <- render(f)
plot(f, type="both")
points(x.test[,1], x.test[,2], cex=10*predict(f, x.test), pch=19)
legend("topleft", c("Traning", "Test"), pch=c(1,19), bg="white")
# Draw random sample from the estimated density
x.new <- radeba(400, f)
plot(f)
points(x.new[,1], x.new[,2])
# Slice the distribution
plot(0, 0, type="n", xlim=c(-4, 12), ylim=c(0, 0.15))
for(i in -6:16){
f <- render(f, list(seq(-4, 12, length.out=200), i))
plot(f, col=hsv(h=(i+6)/30), add=TRUE)
}
plot(f, type="data")
# See package `adebaExtra` for how to plot in full 3d
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.