dirda.cv: Cross validation for estimating the classification rate

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/dirda.cv.R


Cross validation for estimating the classification rate.


dirda.cv(x, ina, folds = NULL, nfolds = 10, k = 2:10, stratified = FALSE,
         type = c("vmf", "iag", "esag", "kent", "sknn", "nsknn"),
         seed = FALSE, B = 1000, parallel = FALSE)



A matrix with the data in Eulcidean coordinates, i.e. unit vectors. The matrix must have three columns, only spherical data are currently supported.


A variable indicating the groupings.


Do you already have a list with the folds? If not, leave this NULL.


How many folds to create?


If you choose to use k-NN, what will be the k values?


Should the folds be created in a stratified way? i.e. keeping the distribution of the groups similar through all folds?


If seed is TRUE, the results will always be the same.


The type of classifier to use. The avaliable options are "vmf" (von Mises-Fisher distribution), "esag" (ESAG distribution), "kent" (Kent distribution), "sknn" (standard k-NN) and "nsknn" (non standard k-NN). You can chose any of them or all of them. Note that "esag" and "kent" work only with spherical data.


If you used k-NN, should a bootstrap correction of the bias be applied? If yes, 1000 is a good value.


If you want the standard -NN algorithm to take place in parallel set this equal to TRUE.


Cross-validation for the estimation of the performance of a classifier.

The estimated performance of the best classifier is overestimated. After the cross-valdiation procedure, the predicted values produced by all classifiers are colelcted, from all folds, in an n \times M matrix, where n is the number of samples and M the number of all classifiers used. We sample rows (predictions) with replacement from P and denote them as the in-sample values. The non re-sampled rows are denoted as out-of-sample values. The performance of each classifier in the insample rows is calculated and the classifier with the optimal performance is selected, followed by the calculation of performance in the out-of-sample values. This process is repeated B times and the average performance is returned. The only computational overhead is with the repetitive resampling and calculation of the performance, i.e. no model or classifier is fitted nor trained. For more information see Tsamardinos et al. (2018). This procedure though takes place only for the k-NN algorithm and is applied to each version standard ("sknn") or non-standard ("nsknn").

The good thing with the function is that you can run any method you want by supplying the folds yourselves using the command makefolds. Then suppose you want to run another method. By suppying the same folds you will be able to have comparative results for all methods.


A list including:


A vector with the estimated performance of each classifier.


The classifier with the optimal performance.


The bootstrap bias corrected performance.


Michail Tsagris

R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.


Tsagris M. and Alenazi A. (2019). Comparison of discriminant analysis methods on the sphere. Communications in Statistics: Case Studies, Data Analysis and Applications, 5(4), 467–491.

Mardia, K. V. and Jupp, P. E. (2000). Directional statistics. Chicester: John Wiley & Sons.

Paine P.J. Preston S.P. & Tsagris M. and Wood A.T.A. (2018). An Elliptically Symmetric Angular Gaussian Distribution. Statistics and Computing, 28(3):689–697.

Morris J. E. & Laycock P. J. (1974). Discriminant analysis of directional data. Biometrika, 61(2): 335-341.

Tsamardinos I., Greasidou E. & Borboudakis G. (2018). Machince Learning, 107(12): 1895-1922. https://doi.org/10.1007/s10994-018-5714-4

See Also

esag.da, vmfda.pred, dirknn, knn.reg


x <- rvmf(300, rnorm(3), 10)
ina <- sample.int(4, 300, replace = TRUE)
dirda.cv(x, ina, B = 1000)

Directional documentation built on Nov. 8, 2021, 1:07 a.m.