gx.mvalloc.closed: Function for Allocation on the basis of Multivariate Data for...

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Function to allocate individuals (observations, cases or samples) from closed compositional, geochemical, data sets 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’.

Usage

1
gx.mvalloc.closed(pcrit = 0.05, xx, ...)

Arguments

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 pcrit = 0.05.

xx

a n by p matrix containing the n individuals, with p variables determined on each, to be allocated, see Details below.

...

a list of objects saved from either function
gx.md.gait.closed or gx.robmva.closed, containing the vectors of means and inverse covariance matrices for the ‘reference’ groups into which the individuals are to be classified.

Details

It is imperative that the data matrix xx contains no special codes, see Note below. It is also imperative that the variables in the reference groups and in the matrix x of individuals to be classified are identical in number 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.

Value

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 reference groups.

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 kk predicted probabilities of reference group memberships.

xalloc

the reference group, 1:kk, that the individual was allocated into. All outliers, i.e. all pgm(1:kk) < crit are allocated to group zero, 0. Therefore xalloc will be in the range of 0:kk.

Note

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 xx prior to executing this function, see ltdl.fix.df. Any rows in the input data matrix xx with NAs are removed prior to computations.

Author(s)

Robert G. Garrett

References

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.

See Also

gx.md.gait.closed, gx.robmva.closed, gx.mvalloc.print, ltdl.fix.df, remove.na, na.omit

Examples

 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
## Make test data available
data(ogrady)
attach(ogrady)
ogrady.grdr <- gx.subset(ogrady, Lith == "GRDR")
ogrady.grnt <- gx.subset(ogrady, Lith == "GRNT")
## Ensure all data are in the same units (mg/kg)
ogrady.grdr.2open <- ogrady.grdr[, c(5:14)]
ogrady.grdr.2open[, 1:7] <- ogrady.grdr.2open[, 1:7] * 10000
ogrady.grnt.2open <- ogrady.grnt[, c(5:14)]
ogrady.grnt.2open[, 1:7] <- ogrady.grnt.2open[, 1:7] * 10000
ogrady.2open <- ogrady[, c(5:14)]
ogrady.2open[, 1:7] <- ogrady.2open[, 1:7] * 10000 

## Create reference data sets
ogrady.grdr.save <- gx.md.gait.closed(as.matrix(ogrady.grdr.2open),
mcdstart = TRUE)
ogrady.grnt.save <- gx.md.gait.closed(as.matrix(ogrady.grnt.2open),
mcdstart = TRUE)

## Allocate all O'Grady granitoids
ogrady.mvalloc <- gx.mvalloc.closed(pcrit = 0.02, as.matrix(ogrady.2open),
ogrady.grdr.save, ogrady.grnt.save)

## Display list of outliers
gx.mvalloc.print(ogrady.mvalloc)

## Display allocations
ogrady.mvalloc$xalloc

## Save allocations as a csv file
gx.mvalloc.print(ogrady.mvalloc, ifprint = FALSE, file = " ")

## Clean-up and detach test data
rm(ogrady.grdr)
rm(ogrady.grnt)
rm(ogrady.grdr.2open)
rm(ogrady.grnt.2open)
rm(ogrady.2open)
rm(ogrady.grdr.save)
rm(ogrady.grnt.save)
rm(ogrady.mvalloc)
detach(ogrady)

Example output

Loading required package: MASS
Loading required package: fastICA
  ** Are the data/parts all in the same measurement units? **
  ** Are the data/parts all in the same measurement units? **
  *** Proceed with Care, n < 5p ***
  ** Are the data/parts all in the same measurement units? **
  k = 2 	 px = 10 	 nx = 110 
  *** Proceed with Care, n < 5p for group as.matrix(ogrady.grdr.2open) ***
  *** Proceed with Care, n < 5p for group as.matrix(ogrady.grnt.2open) ***
  *** Proceed with Great Care, n < 3p for group as.matrix(ogrady.grnt.2open) ***
  Reference Groups:
     1    as.matrix(ogrady.grdr.2open) 
     2    as.matrix(ogrady.grnt.2open) 
  pcrit was set to: 0.02 

  Row    Group  Probabilities of Group Membership:

   1      0    0 0 
   2      0    0 0 
   7      0    0.0142 0 
   8      0    0 0 
   9      0    0 0 
   10      0    1e-04 0 
   21      0    0 0 
   22      0    0 0 
   23      0    1e-04 0 
   24      0    0 0 
   25      0    0 0 
   37      0    0.0086 5e-04 
   39      0    0 0 
   40      0    0 0 
   42      0    0 0 
   55      0    0.0065 0.001 
   61      0    0 0 
   67      0    0 0 
   68      0    0 0 
   69      0    0 0 
   70      0    0 0 
   73      0    0 0 
   74      0    0 0 
   79      0    0 0 
   80      0    0 0 
   81      0    0 0 
   82      0    0 0 
   84      0    0 0 
   105      0    0.0044 0 
   106      0    0 0 

  [1] 0 0 1 1 1 1 0 0 0 0 1 1 1 1 1 2 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 0
 [38] 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 2 2 0 1 1 2 1 1 0 0 0 0 1 1 0 0
 [75] 1 1 1 1 0 0 0 0 2 0 1 2 2 2 1 1 2 1 1 1 1 2 2 2 1 1 2 2 2 2 0 0 2 2 1 1
  Reference Groups:
     1    as.matrix(ogrady.grdr.2open) 
     2    as.matrix(ogrady.grnt.2open) 
  pcrit was set to: 0.02 

  Saved table will be in:
   /work/tmp/ogrady.mvalloc_mvalloc.csv 

rgr documentation built on May 2, 2019, 6:09 a.m.

Related to gx.mvalloc.closed in rgr...