complr {multilevelcoda}R Documentation

Indices from a (dataset of) Multilevel Composition(s)

Description

Compute sets of compositions and log ratio transformation for multilevel compositional data

Usage

complr(data, parts, sbp = NULL, total = 1, idvar = NULL, transform = "ilr")

Arguments

data

A data.frame or data.table containing data of all variables used in the analysis. It must include a composition and a ID variable. Required.

parts

A character vector specifying the names of compositional variables to be used.

sbp

A signary matrix indicating sequential binary partition.

total

A numeric value of the total amount to which the compositions should be closed. Default is 1.

idvar

Only for multilevel data, a character string specifying the name of the variable containing IDs.

transform

A character value naming a log ratio transformation to be applied on compositional data. Can be either "ilr" (isometric logratio), "alr" (additive logratio), or "clr" (centered logratio). Default is "ilr".

Details

The ilr-transform maps the D-part compositional data from the simplex into non-overlapping subgroups in the (D-1)-dimension Euclidean space isometrically by using an orthonormal basis, thereby preserving the compositional properties and yielding a full-rank covariance matrix. ilr transformation should be preferred. However, the alr and clr are alternatives. The alr-transform maps a D-part composition in the Aitchison-simplex non-isometrically to a (D-1)-dimension Euclidian vectors, commonly treating the last part as the common denominator of the others. alr transformation does not rely on distance which breaks the constraint of compositional data. clr-transform maps a D-part composition in the Aitchison-simplex isometrically to a D-dimensional Euclidian vector subspace. clr transformation is not injetive, resulting in singular covariance matrices.

Value

A complr object with at least the following elements.

comp

A vector of class acomp representing one closed composition or a matrix of class acomp representing multiple closed compositions each in one row.

between_comp

A vector of class acomp representing one closed between-person composition or a matrix of class acomp representing multiple closed between-person compositions each in one row.

within_comp

A vector of class acomp representing one closed within-person composition or a matrix of class acomp representing multiple closed within-person compositions each in one row.

logratio

Log ratio transform of composition.

between_logratio

Log ratio transform of between-person composition.

within_logratio

Log ratio transform of within-person composition.

data

The user's dataset or imputed dataset if the input data contains zeros.

transform

Type of transform applied on compositional data.

parts

Names of compositional variables.

idvar

Name of the variable containing IDs.

total

Total amount to which the compositions is closed.

Examples

cilr <- complr(data = mcompd, sbp = sbp,
                parts = c("TST", "WAKE", "MVPA", "LPA", "SB"),
                idvar = "ID", total = 1440)
str(cilr)

calr <- complr(data = mcompd, sbp = sbp,
                parts = c("TST", "WAKE", "MVPA", "LPA", "SB"),
                idvar = "ID",
                transform = "alr")
str(calr)

cclr <- complr(data = mcompd, sbp = sbp,
                parts = c("TST", "WAKE", "MVPA", "LPA", "SB"),
                idvar = "ID",
                 transform = "clr")
str(cclr)

cilr_wide <- complr(data = mcompd[!duplicated(ID)], sbp = sbp,
                parts = c("TST", "WAKE", "MVPA", "LPA", "SB"))
str(cilr_wide)

[Package multilevelcoda version 1.3.0.2 Index]