alfaknnreg.tune: Cross validation for the alpha-k-NN regression with...

View source: R/alfaknnreg.tune.R

Cross validation for the alpha-k-NN regression with compositional predictor variablesR Documentation

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

Description

Cross validation for the α-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 α=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 α-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 α.

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

Michail Tsagris, Abdulaziz Alenazi and Connie Stewart (2020). Non-parametric regression models for compositional data. https://arxiv.org/pdf/2002.05137.pdf

See Also

alfa.rda, alfa.fda, rda.tune

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)

Compositional documentation built on July 8, 2022, 1:06 a.m.