DCV | R Documentation |
Density cross-validation
DCV(
x,
bw,
weights = NULL,
same = FALSE,
kernel = "gaussian",
order = 2,
PIT = FALSE,
chunks = 0,
no.dedup = FALSE
)
x |
A numeric vector, matrix, or data frame containing observations. For density, the points used to compute the density. For kernel regression, the points corresponding to explanatory variables. |
bw |
Candidate bandwidth values: scalar, vector, or a matrix (with columns corresponding to columns of |
weights |
A numeric vector of observation weights (typically counts) to
perform weighted operations. If null, |
same |
Logical: use the same bandwidth for all columns of Note: since DCV requires computing the leave-one-out estimator, repeated observations are combined first; the de-duplication is therefore forced in cross-validation. The only situation where de-duplication can be skipped is passing de-duplicated data sets from outside (e.g. inside optimisers). |
kernel |
Character describing the desired kernel type. NB: due to limited machine precision, even Gaussian has finite support. |
order |
An integer: 2, 4, or 6. Order-2 kernels are the standard kernels that are positive everywhere. Orders 4 and 6 produce some negative values, which reduces bias but may hamper density estimation. |
PIT |
If TRUE, the Probability Integral Transform (PIT) is applied to all columns
of |
chunks |
Integer: the number of chunks to split the task into (limits
RAM usage but increases overhead). |
no.dedup |
Logical: if TRUE, sets |
A numeric vector of the same length as bw
or nrow(bw)
.
set.seed(1)
x <- rlnorm(100); x <- c(x[1], x) # x with 1 duplicate
bws <- exp(seq(-3, 0.5, 0.1))
plot(bws, DCV(x, bws), log = "x", bty = "n", main = "Density CV")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.