| Title: | Simplical-Simplicial Spatial Median Regression for Compositional Data |
|---|---|
| Description: | Simplicial-simplicial regression is performed via the simplicially constrained spatial median regression model. The regression coefficients are constrained to be non-negative and sum to 1. For the spatial median regression the iteratively reweighted least squares algorithm is adopted, where quadratic programming is used to impose the constraints. |
| Authors: | Michail Tsagris [aut, cre] |
| Maintainer: | Michail Tsagris <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 1.0 |
| Built: | 2026-10-12 13:32:20 UTC |
| Source: | https://github.com/cran/Compositionalscsmr |
Simplical-Simplicial Spatial Median Regression for Compositional Data.
| Package: | Compositionalscsmr |
| Type: | Package |
| Version: | 1.0 |
| Date: | 2026-09-02 |
Michail Tsagris <[email protected]>.
Michail Tsagris [email protected]
Aitchison J. (1986). The statistical analysis of compositional data.
-SCSMR model
Cross-validation for the -SCSMR model.
cv.ascsmr(y, x, a = seq(0.1, 1, by = 0.1), tol = 1e-6, eps = 1e-6, nfolds = 10, folds = NULL, seed = NULL)cv.ascsmr(y, x, a = seq(0.1, 1, by = 0.1), tol = 1e-6, eps = 1e-6, nfolds = 10, folds = NULL, seed = NULL)
y |
A numerical matrix with the simplicial response data. Zero values are allowed. |
x |
A matrix with the simplicial predictor variables. Zero values are allowed. |
a |
A vector or a single number of values of the |
tol |
The tolerance value to terminate the IRLS algortihm. |
eps |
A small value to prevent or safeguard agains no solution of the quadratic programming. |
nfolds |
The number of folds for the K-fold cross-validation, set to 10 by default. |
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. |
The K-fold cross-validation is performed in order to select the optimal value for
of the -SCSMR model.
A list including:
runtime |
The runtime of the cross-validation procedure. |
kl |
The Kullback-Leibler divergence for every value of |
js |
The Jensen-Shannon divergence for every value of |
Michail Tsagris.
R implementation and documentation: Michail Tsagris [email protected].
Tsagris. M. (2025). Constrained least squares simplicial-simplicial regression. Statistics and Computing, 35(27).
y <- as.matrix(iris[, 1:4]) x <- matrix( rgamma(450, 3, 5), ncol = 3) x <- x / rowSums(x) mod <- cv.ascsmr(y, x, nfolds = 5)y <- as.matrix(iris[, 1:4]) x <- matrix( rgamma(450, 3, 5), ncol = 3) x <- x / rowSums(x) mod <- cv.ascsmr(y, x, nfolds = 5)
Permutation linear independence test in the SCSMR model.
scsmr.indeptest(y, x, tol = 1e-6, eps = 1e-6, R = 999)scsmr.indeptest(y, x, tol = 1e-6, eps = 1e-6, R = 999)
y |
A matrix with the compositional data (dependent variable). Zero values are allowed. |
x |
A matrix with the compositional predictors. Zero values are allowed. |
tol |
The tolerance value to terminate the IRLS algortihm. |
eps |
A small value to prevent or safeguard agains no solution of the quadratic programming. |
R |
The number of permutations to perform. |
Permutation independence test in the constrained spatial median regression for compositional
responses and predictors is performed. The observed test statistic is the square root of the
of the sum of squares of the errors computed by scsmr.
Then, the rows of X are permuted B times and each time the constrained spatial median regression
is performed and the sum is again computed. The p-value is then computed in the usual way.
The p-value for the test of independence between Y and X.
Michail Tsagris.
R implementation and documentation: Michail Tsagris [email protected].
Tsagris. M. (2025). Constrained least squares simplicial-simplicial regression. Statistics and Computing, 35(27).
y <- as.matrix(iris[, 1:4]) x <- matrix( rgamma(450, 3, 5), ncol = 3) x <- x / rowSums(x) scsmr.indeptest(y, x, R = 99)y <- as.matrix(iris[, 1:4]) x <- matrix( rgamma(450, 3, 5), ncol = 3) x <- x / rowSums(x) scsmr.indeptest(y, x, R = 99)
Ternary diagram with confidence region for the matrix of coefficients of the SCSMR model.
ternary.coefcr(y, x, conf = 0.95, R = 1000, dg = FALSE, hg = FALSE)ternary.coefcr(y, x, conf = 0.95, R = 1000, dg = FALSE, hg = FALSE)
y |
A matrix with the response compositional data. |
x |
A matrix with the predictor compositional data. |
conf |
The confidence level, by default this is set to 0.95. |
R |
Number of bootstrap replicates to run. |
dg |
Do you want diagonal grid lines to appear? If yes, set this TRUE. |
hg |
Do you want horizontal grid lines to appear? If yes, set this TRUE. |
This function runs the SCLS or the TFLR model and constructs confidence regions for the estimated matrix of regression coefficients using non-parametric bootstrap.
A ternary plot of the estimated matrix of coefficients of the SCLS or of the TFLR model, and their associated confidence regions.
Michail Tsagris.
R implementation and documentation: Michail Tsagris [email protected].
Tsagris. M. (2025). Constrained least squares simplicial-simplicial regression. Statistics and Computing, 35(27).
y <- as.matrix(iris[, 1:3]) y <- y / rowSums(y) x <- matrix( rgamma(450, 3, 5), ncol = 3)y <- as.matrix(iris[, 1:3]) y <- y / rowSums(y) x <- matrix( rgamma(450, 3, 5), ncol = 3)
Ternary diagram with the coefficients of the SCSMR model.
ternary.coef(B, dg = FALSE, hg = FALSE, colour = NULL)ternary.coef(B, dg = FALSE, hg = FALSE, colour = NULL)
B |
A matrix with the coefficients of the |
dg |
Do you want diagonal grid lines to appear? If yes, set this TRUE. |
hg |
Do you want horizontal grid lines to appear? If yes, set this TRUE. |
colour |
If you want the points to appear in different colour put a vector with the colour numbers or colours. |
Ternary plot of the coefficients of the scsmr function.
A ternary plot of the coefficients of the scsmr function.
Michail Tsagris.
R implementation and documentation: Michail Tsagris [email protected].
Tsagris. M. (2025). Constrained least squares simplicial-simplicial regression. Statistics and Computing, 35(27).
y <- as.matrix(iris[, 1:3]) y <- y / rowSums(y) x <- matrix( rgamma(450, 3, 5), ncol = 3) mod <- scsmr(y, x) ternary.coef(mod$be)y <- as.matrix(iris[, 1:3]) y <- y / rowSums(y) x <- matrix( rgamma(450, 3, 5), ncol = 3) mod <- scsmr(y, x) ternary.coef(mod$be)
-SCSMR model for compositional responses and predictors
The -SCSMR model for compositional responses and predictors.
ascsmr(y, x, a = seq(0.1, 1, by = 0.1), tol = 1e-6, eps = 1e-6, xnew)ascsmr(y, x, a = seq(0.1, 1, by = 0.1), tol = 1e-6, eps = 1e-6, xnew)
y |
A matrix with the compositional data (dependent variable). Zero values are allowed. |
x |
A matrix with the compositional predictors. Zero values are allowed. |
a |
A vector or a single number of values of the |
tol |
The tolerance value to terminate the IRLS algortihm. |
eps |
A small value to prevent or safeguard agains no solution of the quadratic programming. |
xnew |
The new data for which predictions will be made. |
This is an extension of the SCSMR model that includes the -transformation and
is intended solely for prediction purposes.
A list with matrices containing the predicted simplicial response values,
one matrix for each value of .
Michail Tsagris.
R implementation and documentation: Michail Tsagris [email protected].
Tsagris. M. (2025). Constrained least squares simplicial-simplicial regression. Statistics and Computing, 35(27).
set.seed(1234) y <- as.matrix(iris[, 1:4]) x <- matrix( rgamma(450, 3, 5), ncol = 3) x <- x / rowSums(x) mod <- ascsmr(y, x, xnew = x) modset.seed(1234) y <- as.matrix(iris[, 1:4]) x <- matrix( rgamma(450, 3, 5), ncol = 3) x <- x / rowSums(x) mod <- ascsmr(y, x, xnew = x) mod
Simplicial constrained spatial median regressio (SCSMR) for compositional responses and predictors.
scsmr(y, x, xnew = NULL, tol = 1e-06, eps = 1e-6)scsmr(y, x, xnew = NULL, tol = 1e-06, eps = 1e-6)
y |
A matrix with the compositional data (dependent variable). Zero values are allowed. |
x |
A matrix with the compositional predictors. Zero values are allowed. |
xnew |
If you have new data use it, otherwise leave it NULL. |
tol |
The tolerance value to terminate the IRLS algortihm. |
eps |
A small value to prevent or safeguard agains no solution of the quadratic programming. |
The function performs spatial median regression where the beta coefficients are constained to be positive and sum to 1. The inspiration came from the SCLS model of Tsagris (2025). The function uses quadratic programming (package quadprog) and the solution is fast.
The SCSMR model adopts the same link as TFLR and SCLS between the simplicial response and predictor variables, but only this time the
elements of are estimated by minimizing the norm of the residuals
The first option is the strategy implemented in the Rfast package. The function spatmed.reg() employs an iterative algorithm similar
to that for the spatial median. The iteratively reweighted least squares (IRLS) algorithm works as follows. Beginning with an
initial estimate of the regression coefficients using least squares,
,
the algorithm iterates the following steps until convergence:
,
if and otherwise
We adopt the above steps to the simplicial setting by changing Step 4, and instead of the
classical least squares we fit a weighted SCLS model. At iteration of the IRLS algorithm,
we need to solve the following constrained weighted least squares problem, which is solved
via quadratic programming (QP).
subject to
and
A list including:
norm |
The mean of the square root of the sum of squares. |
be |
The beta coefficients. |
est |
The fitted of xnew if xnew is not NULL. |
Michail Tsagris.
R implementation and documentation: Michail Tsagris [email protected].
Tsagris. M. (2025). Constrained least squares simplicial-simplicial regression. Statistics and Computing, 35(27).
y <- as.matrix(iris[, 1:4]) x <- matrix( rgamma(450, 3, 5), ncol = 3) x <- x / rowSums(x) mod <- scsmr(y, x) mody <- as.matrix(iris[, 1:4]) x <- matrix( rgamma(450, 3, 5), ncol = 3) x <- x / rowSums(x) mod <- scsmr(y, x) mod