Description Usage Arguments Details Value Note Author(s) References See Also Examples
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’.
1 | 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.
gx.md.gait
, gx.md.gait.closed
, gx.mva
, gx.robmva
, gx.robmva.closed
, gx.mvalloc.print
, ltdl.fix.df
, remove.na
, na.omit
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | ## 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)
|
Loading required package: MASS
Loading required package: fastICA
k = 3 px = 2 nx = 306
Reference Groups:
1 grp1[, -3]
2 grp2[, -3]
3 grp3[, -3]
pcrit was set to: 0.05
Row Group Probabilities of Group Membership:
2 0 0.008 0 0
27 0 0.0336 0 0
30 0 0.0211 0 0
95 0 0.0291 0 0
132 0 0 0.0331 0
142 0 0 0.0226 0
178 0 0 0.0166 0
196 0 0 0.0346 0
211 0 0 0 0.0403
223 0 0 0 0.0253
225 0 0 0 0.0089
233 0 0 0 0.0485
236 0 0 0 9e-04
237 0 0 0 0.0108
238 0 0 0 0.0352
246 0 0 0 0.0262
250 0 0 0 0.0366
272 0 0 0 0.0374
286 0 0 0 0.0374
290 0 0 0 0.0378
301 0 0 0 0
302 0 0 0 0
303 0 0 0 0
304 0 0 0 0
305 0 0 0 0
306 0 0 0 0
Reference Groups:
1 grp1[, -3]
2 grp2[, -3]
3 grp3[, -3]
pcrit was set to: 0.05
Saved table will be in:
/work/tmp/test.save.mvalloc_mvalloc.csv
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.