View source: R/alfaknnreg.tune.R

Cross validation for the alpha-k-NN regression with compositional predictor variables | R Documentation |

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 = NULL, 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 |

`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). Non-parametric regression models for compositional data. https://arxiv.org/pdf/2002.05137.pdf

` alfa.rda, alfa.fda, rda.tune `

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)

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.