zVarArray: Variation array for grouped data

View source: R/zVarArray.R

zVarArrayR Documentation

Variation array for grouped data

Description

This function returns overall and separate variation arrays for groups in a compositional data set. Groups can be defined by either zero/unobserved data patterns or by a grouping factor in fully observed zero-free data sets.

Usage

zVarArray(X, label = 0, groups = NULL, suppress.print = FALSE)

Arguments

X

Compositional data set (matrix or data.frame class).

label

Unique label (numeric or character) used to denote zeros/unobserved data in X (label = 0, default).

groups

Grouping factor in fully observed zero-free data sets (groups = NULL, default).

suppress.print

Suppress printed feedback (suppress.print = FALSE, default).

Details

This function is mainly aimed to investigate heterogeneous relative variation structures in compositional data sets containing zeros or unobserved values. For each pattern of zero or unobserved values, log-ratio variances (upper triangle of variation matrix) and means (lower triangle of variation matrix) are computed from the available data. Note that (1) NAs are produced for log-ratio variances and means in groups containing less than two observations, and (2) at least two components must be available in each group to compute log-ratios.

The overall estimate is obtained across groups by pairwise deletion. Note that, unlike the ordinary var function, maximum likelihood estimates of the variances are computed. That is, the observed sum of squares is divided by the corresponding number of observations n and not by n-1.

Group-wise variation arrays can be obtained from fully observed zero-free data by setting a grouping factor using the argument groups.

Value

List of variation arrays by pattern/group and overall.

See Also

zPatterns.

Examples

data(Water)
zPatterns(Water, label = 0)
zVarArray(Water)

# From a completed data set

data(mdl) # matrix of limits of detection for Water
Water_multKM <- multKM(Water,label=0,dl=mdl) # nondetects imputation

# Results split by two ficticious groups A and B
zVarArray(Water_multKM,groups=rep(c("A","B"),each=50))

zCompositions documentation built on Aug. 24, 2023, 1:08 a.m.