Description Usage Arguments Details Value References See Also Examples
View source: R/peeling_trajectory.R
Performs k-fold cross-validation on peeling for choosing the stopping criterion.
1 | cv.trajectory(y, x, grid = NULL, folds = NULL, nfolds = 10, ...)
|
y |
Numeric vector of response values. |
x |
Numeric or categorical data.frame of input values. |
grid |
Vector of stopping supports
for peeling trajectory prediction.
If NULL (the default), an initial peeling is carried out on the
whole data and its |
folds |
An integer vector giving the fold index of each observation.
If NULL (the default)
|
nfolds |
Integer giving the number of folds to create if |
... |
Additional arguments to be passed to |
The cv.trajectory function splits the provided data into
nfolds several folds. The peeling is carried out on
nfolds - 1 folds and the objective function is computed on the
remaining fold. This process is repeated excluding each fold successively
and the resulting trajectories are averaged at each value in
grid.
Folds can be given either directly through the argument folds or
randomly generated using the argument nfolds.
A cv.prim object that can be used in methods for prim
objects (e.g. plot_trajectory). Contains the elements:
support |
The support grid provided in the argument
|
yfun |
The cross-validated objective function values at each
|
se.yfun |
Cross-validation standard errors associated with
|
x,y |
The input and response data used. |
numeric.vars |
A logical vector indicating, for each input variable, if it was considered as a numeric variable. |
alpha, peeling.side, obj.fun |
The value of the arguments used for peeling. Useful for prim methods. |
Friedman, J.H., Fisher, N.I., 1999. Bump hunting in high-dimensional data. Statistics and Computing 9, 123-143. https://doi.org/10.1023/A:1008894516817
peeling for the peeling algorithm used in the
function. plot_trajectory to analyse the cross-validated
trajectory.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # A simple bump
set.seed(12345)
x <- matrix(runif(2000), ncol = 2, dimnames = list(NULL, c("x1", "x2")))
y <- 2 * x[,1] + 5 * x[,2] + 10 * (x[,1] >= .8 & x[,2] >= .5) + rnorm(1000)
# 10-fold cross-validation
cv_res <- cv.trajectory(y, x)
# Display the cross-validated trajectory
plot_trajectory(cv_res, type = "b", pch = 16, col = "cornflowerblue",
support = 0.1, npeel = which.max(cv_res$yfun),
abline.pars = list(lwd = 2, col = "indianred"),
xlab = "", xlim = c(0, 0.2), ylim = c(10, 18))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.