fences: Generate and Display Fence Values

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

View source: R/fences.R

Description

Function to generate fence values to support the selection of the upper and lower bounds of background variability, i.e. threshold(s) or action levels, when an obvious graphical solution is not visually recognizable.

Usage

1
fences(xx, units = "ppm", display = TRUE)

Arguments

xx

name of the variable to be processed.

units

the units of measurement, options are: “pct”, “ppm”, “ppb”, “ppt”. The default is “ppm”.

display

the default is to display the tabular output on the current device, i.e. display = TRUE. However, when the function is used by fences.summary and in order to suppress output to the current device display = FALSE as the displayed results will be saved to a text file for subsequent use/editing and reference.

Details

The fence values are computed by several procedures both with and without a logarithic data transformation and with a logit transformation, together with the 98th percentile of the data for display. Fences are computed following Tukey's boxplot procedure, as median +/- 2 * MAD (Median Absolute Deviation), and mean +/- 2 * SD (Standard Deviation), see Reimann et al. (2005). It is essential that these estimates be viewed in the context of the graphical distributional displays, e.g., shape and its graphical components, gx.hist, gx.ecdf, cnpplt and bxplot, and if spatial coordinates for the sample sites are available map.eda7, map.eda8 and caplot. The final selection of a range for background or the selection of a threshold level needs to take the statistical and spatial distributions of the data into account. It is also necessary to be aware that it might be appropriate to have more than one background range/threshold in a study or survey (Reimann and Garrett, 2005). The presence of relevant information in the data frame may permit the data to be subset on the basis of that information for display with the tbplots, bwplots and gx.cnpplts functions. If these indicate that the medians and middle 50%s of the data are visibly different, multiple background ranges may be advisable.

Note

The logit transformation requires that the input value be in the range zero to one. This transformation takes into consideration the closed, constant sum, nature of geochemical analytical data (Filzmoser et al., 2009). Therefore the measurement units must be defined so that the the value can be divided by the appropriate constant. The default is “ppm”, and other acceptable units are “pct”, “ppb” and “ppt”. However, it should be noted that at trace element levels the differences between fences computed with logarithmic and logit transformations are small, and in most applied geochemical applications the logarithmic transformation will suffice. This is not the case for concentrations at major element levels, where the data are more ‘normally’ distributed and fences will be markedly different between untransformed and logit based estimates.

Any less than detection limit values represented by negative values, or zeros or other numeric codes representing blanks in the data, must be removed prior to executing this function, see ltdl.fix.df.

Any NAs in the data vector are removed prior to computing the fences.

Author(s)

Robert G. Garrett

References

Filzmoser, P., Hron, K. and Reimann, C., 2009. Univariate statistical analysis of environmental (compositional) data: Problems and possibilities. Science of the Total Environment, 407(1/3):6100-6108.

Reimann, C. and Garrett, R.G., 2005. Geochemical background - Concept and reality. Science of the Total Environment, 350(1-3):12-27.

Reimann, C., Filzmoser, P. and Garrett, R.G., 2005. Background and threshold: critical comparison of methods of determination. Science of the Total Environment, 346(1-3):1-16.

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

fences.summary, ltdl.fix.df, remove.na, logit, expit

Examples

1
2
3
4
5
6
7
8
9
## Make test data available
data(kola.o)
attach(kola.o)

## Display the fences computed for Cu
fences(Cu)

## Detach test data
detach(kola.o)     

Example output

Loading required package: MASS\nLoading required package: fastICA\n  Cu (Units = ppm ) :  N = 617     NAs = 0 \t2%ile = 4.7 \t98%ile = 241 \n\t Mean\t SD\t  Median   MAD\t\t Mean\t\t Med\t       Tukey Fences\n \t\t\t\t\t\t \xb12SD\t\t \xb12MAD\t\t     (actual)\n\t 43.7 \t 245 \t   9.69    5.14 \t 535 \t\t 20 \t       35.2  ( 34.9 ) \n\t\t\t\t\t\t -447 \t\t -0.599 \t       -10.2  ( 2.69 ) \n  Log10\t 1.12 \t 0.432 \t   0.986    0.267 \t 96.3 \t\t 33.2 \t       78.8  ( 76.1 ) \n\t\t\t\t\t\t 1.8 \t\t 2.83 \t       1.58  ( 2.69 ) \n  Logit\t -11.2 \t 0.995 \t   -11.5   0.615 \t 96.3 \t\t 33.1 \t       78.8  ( 76.1 ) \n\t\t\t\t\t\t 1.8 \t\t 1.32 \t       1.58  ( 2.69 )\nWarning messages:\n1: input string \'\t\t\t\t\t\t \xb12SD\t\t \xb12MAD\t\t     (actual)\n\t\' cannot be translated to UTF-8, is it valid in \'ANSI_X3.4-1968\'? \n2: input string \'\t\t\t\t\t\t \xb12SD\t\t \xb12MAD\t\t     (actual)\n\t\' cannot be translated to UTF-8, is it valid in \'ANSI_X3.4-1968\'? \nsh: 1: rm: Permission denied\n

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

Related to fences in rgr...