Function for Allocation on the basis of Multivariate Data
Function to allocate individuals (observations, cases or samples) into one of multiple reference groups (populations) on the basis of their Mahalanobis distances. If an individual's predicted probability of group membership (typicality) falls below a user defined ‘cut-off’, pcrit
, the individual is allocated to an ‘outlier bin’.
gx.mvalloc(pcrit = 0.05, x, ...)
pcrit |
the critical cut-off probability for group membership below which an individual will be classified as an ‘outlier’. By default the critical probability of group membership is set to |
x |
a |
... |
a list of objects saved from any of functions |
It is imperative that the data matrix x
contains no special codes and all records (individuals) with NAs have been removed, see Notes below. It is also imperative that the variables in the reference groups and in the matrix x
of individuals to be classified are identical and in the same order.
The allocations are made on the assumption that the covariance structures are inhomogeneous, i.e. that the population hyperellipsoids are of different size, shape and orientation in p
-space.
The following are returned as an object to be saved for display with gx.mvalloc.print
:
groups |
a list of the names of the |
kk |
the number of reference groups passed to the function. |
n |
the number of individuals (observations, cases or samples) allocated. |
p |
the number of variables in the reference and allocated data. |
pcrit |
the critical cut-off probability for reference group membership. |
pgm |
a vector of |
xalloc |
the reference group, |
Any less than detection limit values represented by negative values, or zeros or other numeric codes representing blanks in the data, must be removed from the matrix x
prior to executing this function, see ltdl.fix.df
. Additionally, any rows in the data matrix with NA
s also must have been removed prior to computations, see na.omit
and remove.na
.
It is recommended that when applying this procedure to compositional data an ilr transformation be undertaken, this can be done at execution time. This implies that the reference group means and covariance matrices must have also been estimated following an ilr transformation.
Robert G. Garrett
Garrett, R.G., 1990. A robust multivariate allocation procedure with applications to geochemical data. In Proc. Colloquium on Statistical Applications in the Earth Sciences (Eds F.P. Agterberg & G.F. Bonham-Carter). Geological Survey of Canada Paper 89-9, pp. 309-318.
Reimann, C., Filzmoser, P., Garrett, R. and Dutter, R., 2008. Statistical Data Analysis Explained: Applied Environmental Statistics with R. John Wiley & Sons, Ltd., 362 p.
## Generate three groups of synthetic bivariate normal data grp1 <- mvrnorm(100, mu = c(40, 30), Sigma = matrix(c(6, 3, 3, 2), 2, 2)) grp1 <- cbind(grp1, rep(1, 100)) grp2 <- mvrnorm(100 ,mu = c(50, 40), Sigma = matrix(c(4, -3, -3, 5), 2, 2)) grp2 <- cbind(grp2, rep(2, 100)) grp3 <- mvrnorm(100 ,mu = c(30, 45), Sigma = matrix(c(6, 4, 4, 5), 2, 2)) grp3 <- cbind(grp3 ,rep(3, 100)) ## Generate a set of six (6) outliers anom <- matrix(c(35, 40, 25, 60, 25, 60, 35, 40, 25, 60, 60, 25),6, 2) anom <- cbind(anom, rep(4, 6)) ## Bind the test data sets together and display the test data test.mvalloc.mat <- rbind(grp1, grp2, grp3, anom) test.mvalloc <- as.data.frame(test.mvalloc.mat) dimnames(test.mvalloc)[[2]] <- c("x","y","grp") attach(test.mvalloc) xyplot.tags(x, y, grp, cex = 0.75) ## Generate robust reference groups test.save.grp1 <- gx.md.gait(grp1[, -3], mcdstart = TRUE) test.save.grp2 <- gx.md.gait(grp2[, -3], mcdstart = TRUE) test.save.grp3 <- gx.md.gait(grp3[, -3], mcdstart = TRUE) ## Allocate the synthetic data into the three reference groups test.save.mvalloc <- gx.mvalloc(pcrit = 0.05, test.mvalloc.mat[,-3], test.save.grp1, test.save.grp2, test.save.grp3) ## Display the results of the allocation xyplot.tags(x, y, test.save.mvalloc$xalloc, cex = 0.75) gx.mvalloc.print(test.save.mvalloc) ## Save the allocation as a csv file gx.mvalloc.print(test.save.mvalloc, ifprint = FALSE, file = " ") ## Clean-up and detach synthetic test data rm(grp1) rm(grp2) rm(grp3) rm(anom) rm(test.mvalloc) rm(test.save.grp1) rm(test.save.grp2) rm(test.save.grp3) rm(test.save.mvalloc) detach(test.mvalloc)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.