Learn R Programming

compositions (version 2.0-8)

gsi.varwithlosts: Internal function: computes variance of compositional data set with missing/zero values

Description

Computes an unbiased estimate of the variance of a compositional data set with some missing and zero values.

Usage

gsi.varwithlosts(x,giveCenter=FALSE)

Value

A variance matrix using all the observed information, where some of its components have been downweighted to account for the missing values. ATTENTION: function quite slow. It will be called directly by var.acomp

and similar generic functions only if na.action is set to na.pass.

Arguments

x

data set of the classes in compositions

giveCenter

a logical. If TRUE the function reports the mean as an attribute "center" to the result.

Author

R. Tolosana-Delgado, K.Gerald v.d. Boogaart http://www.stat.boogaart.de

References

van den Boogaart, K. G., R. Tolosana-Delgado, and M. Bren (2006) Concepts for handling of zeros and missing values in compositional data, In: 2006 Annual Conference of the International Association for Mathematical Geology (IAMG), Universit\'e de Li\`ege, Belgium.

Bren, M., R. Tolosana-Delgado, and K.G. van den Boogaart (2008) News from compositions, the R package. In: Daunis-i-Estadella, J. and Mart\'in-Fern\'a ndez, J.A. (Eds.) Proceedings of the 3rd International Workshop on Compositional Data Analysis, Universitat de Girona, Spain. https://ima.udg.edu/Activitats/CoDaWork03/

Examples

Run this code
# generates a 3-part compositional data set with missings
A <- matrix(c(0.5,0.3,0.1, 0.3,0.2,0, 0.1, 0, 0.75),nrow=3)
Mvar <- 2*ilrvar2clr(A)
Mcenter <- acomp(c(1,5,2,3))
x <- rnorm.acomp(100,Mcenter,Mvar) 
colnames(x)<-c("A","B","C","D")
# eliminate 20 values completely at random
 slost <- sample(1:length(x), size=30)
 x[slost] <- 0
# compute the variance with losts
#print(vr <- gsi.varwithlosts(cdt(x)))
# compare with Mvar

Run the code above in your browser using DataLab