cv.olscompcomp: Cross-validation for the constrained linear least squares for...

View source: R/cv.olscompcomp.R

Cross-validation for the constrained linear least squares for compositional responses and predictorsR Documentation

Cross-validation for the constrained linear least squares for compositional responses and predictors

Description

Cross-validation for the constrained linear least squares for compositional responses and predictors.

Usage

cv.olscompcomp(y, x, tol = 1e-4, nfolds = 10,
folds = NULL, seed = NULL)

Arguments

y

A matrix with compositional response data. Zero values are allowed.

x

A matrix with compositional predictors. Zero values are allowed.

tol

The threshold upon which to stop the iterations of the constrained optimisation.

nfolds

The number of folds to be used. This is taken into consideration only if the folds argument is not supplied.

folds

If you have the list with the folds supply it here. You can also leave it NULL and it will create folds.

seed

You can specify your own seed number here or leave it NULL.

Details

The function performs k-fold cross-validation for the least squares regression where the beta coefficients are constained to be positive and sum to 1.

Value

A list including:

runtime

The runtime of the cross-validation procedure.

kl

The Kullback-Leibler divergences for all runs.

js

The Jensen-Shannon divergences for all runs.

perf

The average Kullback-Leibler divergence and average Jensen-Shannon divergence.

Author(s)

Michail Tsagris.

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

See Also

ols.compcomp, cv.tflr, klalfapcr.tune

Examples


library(MASS)
set.seed(1234)
y <- rdiri(214, runif(3, 1, 3))
x <- as.matrix(fgl[, 2:9])
x <- x / rowSums(x)
mod <- cv.olscompcomp(y, x, tol = 1e-4, nfolds = 5, seed = 12345)
mod


Compositional documentation built on Oct. 23, 2023, 5:09 p.m.