Cross validation for the alpha-k-NN regression with compositional response data {Compositional} | R Documentation |
Cross validation for the \alpha
-k-NN regression with compositional response data
Description
Cross validation for the \alpha
-k-NN regression with compositional response data.
Usage
aknnreg.tune(y, x, a = seq(0.1, 1, by = 0.1), k = 2:10, apostasi = "euclidean",
nfolds = 10, folds = NULL, seed = NULL, rann = FALSE)
Arguments
y |
A matrix with the compositional response data. Zeros are allowed. |
x |
A matrix with the available predictor variables. |
a |
A vector with a grid of values of the power transformation, it has to be between -1 and 1. If zero values are present it has to be greater than 0.
If |
k |
The number of nearest neighbours to consider. It can be a single number or a vector. |
apostasi |
The type of distance to use, either "euclidean" or "manhattan". |
nfolds |
The number of folds. Set to 10 by default. |
folds |
If you have the list with the folds supply it here. You can also leave it NULL and it will create folds. |
seed |
You can specify your own seed number here or leave it NULL. |
rann |
If you have large scale datasets and want a faster k-NN search, you can use kd-trees implemented in the R package "Rnanoflann". In this case you must set this argument equal to TRUE. Note however, that in this case, the only available distance is by default "euclidean". |
Details
A k-fold cross validation for the \alpha
-k-NN regression for compositional response data is performed.
Value
A list including:
kl |
The Kullback-Leibler divergence for all combinations of |
js |
The Jensen-Shannon divergence for all combinations of |
klmin |
The minimum Kullback-Leibler divergence. |
jsmin |
The minimum Jensen-Shannon divergence. |
kl.alpha |
The optimal |
kl.k |
The optimal |
js.alpha |
The optimal |
js.k |
The optimal |
runtime |
The runtime of the cross-validation procedure. |
Author(s)
Michail Tsagris.
R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.
References
Tsagris M., Alenazi A. and Stewart C. (2023). Flexible non-parametric regression models for compositional response data with zeros. Statistics and Computing, 33(106).
https://link.springer.com/article/10.1007/s11222-023-10277-5
See Also
aknn.reg, akernreg.tune, akern.reg, alfa.rda, alfa.fda
Examples
y <- as.matrix( iris[, 1:3] )
y <- y / rowSums(y)
x <- iris[, 4]
mod <- aknnreg.tune(y, x, a = c(0.4, 0.6), k = 2:4, nfolds = 5)