Cross validation for the α-k-NN regression with compositional predictor variables
Cross validation for the α-k-NN regression with compositional predictor variables.
alfaknnreg.tune(y, x, a = seq(-1, 1, by = 0.1), k = 2:10, nfolds = 10, apostasi = "euclidean", method = "average", folds = NULL, seed = FALSE, graph = FALSE)
y |
The response variable, a numerical vector. |
x |
A matrix with the available compositional data. Zeros are allowed. |
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 α=0 the isometric log-ratio transformation is applied. |
k |
The number of nearest neighbours to consider. It can be a single number or a vector. |
nfolds |
The number of folds. Set to 10 by default. |
apostasi |
The type of distance to use, either "euclidean" or "manhattan". |
method |
If you want to take the average of the reponses of the k closest observations, type "average". For the median, type "median" and for the harmonic mean, type "harmonic". |
folds |
If you have the list with the folds supply it here. You can also leave it NULL and it will create folds. |
seed |
If seed is TRUE the results will always be the same. |
graph |
If graph is TRUE (default value) a filled contour plot will appear. |
A k-fold cross validation for the α-k-NN regression for compositional response data is performed.
A list including:
mspe |
The mean square error of prediction. |
performance |
The minimum mean square error of prediction. |
opt_a |
The optimal value of α. |
opt_k |
The optimal value of k. |
runtime |
The runtime of the cross-validation procedure. |
Michail Tsagris
R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.
Michail Tsagris, Abdulaziz Alenazi and Connie Stewart (2020). The alpha-k-NN- regression for compositional data. https://arxiv.org/pdf/2002.05137.pdf
library(MASS) x <- as.matrix(fgl[, 2:9]) x <- x / rowSums(x) y <- fgl[, 1] mod <- alfaknnreg.tune(y, x, a = seq(0.2, 0.4, by = 0.1), k = 2:4, nfolds = 5)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.