bpcReg | R Documentation |
Performs classical or robust regression analysis of real response on compositional predictors, represented in backwards pivot coordinates. Also non-compositional covariates can be included (additively).
bpcReg(
X,
y,
external = NULL,
norm.cat = NULL,
robust = FALSE,
base = exp(1),
norm.const = F,
seed = 8
)
X |
object of class data.frame with compositional (positive values only) and non-compositional predictors. The response y can be also included. |
y |
character with the name of response (if included in X) or an array with values of the response. |
external |
array with names of non-compositional predictors. |
norm.cat |
the rationing category placed at the first position in the composition. If not defined, all pairwise logratios are considered. Given in quotation marks. |
robust |
if TRUE, the MM-type estimator is used. Defaults to FALSE. |
base |
a positive number: the base with respect to which logarithms are computed. Defaults to exp(1). |
norm.const |
if TRUE, the regression coefficients corresponding to orthonormal coordinates are given a s result. Defaults to FALSE, the normalising constant is omitted. |
seed |
a single value. |
bpcReg
The compositional part of the data set is repeatedly expressed in a set of backwards logratio coordinates, when each set highlights one pairwise logratio (or one pairwise logratio with the selected rationing category). For each set (supplemented by non-compositonal predictors), robust MM or classical least squares estimate of regression coefficients is performed and information respective to the first backwards pivot coordinate is stored. The summary therefore collects results from several regression models, each leading to the same overall model characteristics, like the F statistics or R^2. The coordinates are structured as detailed in Nesrstova et al. (2023). In order to maintain consistency of the iterative results collected in the output, a seed is set before robust estimation of each of the models considered. Its specific value can be set via parameter seed.
A list containing:
the summary object which collects results from all coordinate systems. The names of the coefficients indicate the type of the respective coordinate (bpc.1 - the first backwards pivot coordinate) and the logratio quantified thereby. E.g. bpc.1_C2.to.C1 would therefore correspond to the logratio between compositional parts C1 and C2, schematically written log(C2/C1). See Nesrstova et al. (2023) for details.
the base with respect to which logarithms are computed
the values of normalising constants (when results for orthonormal coordinates are reported).
TRUE if the MM estimator was applied.
the lm object resulting from the first iteration.
the order of compositional parts cosidered in the first iteration.
Kamila Facevicova
Hron, K., Coenders, G., Filzmoser, P., Palarea-Albaladejo, J., Famera, M., Matys Grygar, M. (2022). Analysing pairwise logratios revisited. Mathematical Geosciences 53, 1643 - 1666.
Nesrstova, V., Jaskova, P., Pavlu, I., Hron, K., Palarea-Albaladejo, J., Gaba, A., Pelclova, J., Facevicova, K. (2023). Simple enough, but not simpler: Reconsidering additive logratio coordinates in compositional analysis. Submitted
bpc
bpcPca
bpcRegTab
## How the total household expenditures in EU Member
## States depend on relative contributions of
## single household expenditures:
data(expendituresEU)
y <- as.numeric(apply(expendituresEU,1,sum))
# classical regression summarizing the effect of all pairwise logratios
lm.cla <- bpcReg(expendituresEU, y)
lm.cla
# gives the same model characteristics as lmCoDaX:
lm <- lmCoDaX(y, expendituresEU, method="classical")
lm$ilr
# robust regression, with Food as the rationing category and logarithm of base 2
# response is part of the data matrix X
expendituresEU.y <- data.frame(expendituresEU, total = y)
lm.rob <- bpcReg(expendituresEU.y, "total", norm.cat = "Food", robust = TRUE, base = 2)
lm.rob
## Illustrative example with exports and imports (categorized) as non-compositional covariates
data(economy)
X.ext <- economy[!economy$country2 %in% c("HR", "NO", "CH"), c("exports", "imports")]
X.ext$imports.cat <- cut(X.ext$imports, quantile(X.ext$imports, c(0, 1/3, 2/3, 1)),
labels = c("A", "B", "C"), include.lowest = TRUE)
X.y.ext <- data.frame(expendituresEU.y, X.ext[, c("exports", "imports.cat")])
lm.ext <- bpcReg(X.y.ext, y = "total", external = c("exports", "imports.cat"))
lm.ext
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.