Cross validation for the alpha-k-NN regression with compositional predictor variables {Compositional}R Documentation

Cross validation for the \alpha-k-NN regression with compositional predictor variables

Description

Cross validation for the \alpha-k-NN regression with compositional predictor variables.

Usage

alfaknnreg.tune(y, x, a = seq(-1, 1, by = 0.1), k = 2:10, nfolds = 10,
apostasi = "euclidean", method = "average", folds = NULL, seed = NULL, graph = FALSE)

Arguments

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 \alpha=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.

Details

A k-fold cross validation for the \alpha-k-NN regression for compositional response data is performed.

Value

A list including:

mspe

The mean square error of prediction.

performance

The minimum mean square error of prediction.

opt_a

The optimal value of \alpha.

opt_k

The optimal value of k.

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

alfa.rda, alfa.fda

Examples

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)

[Package Compositional version 6.9 Index]