Learn R Programming

rgr (version 1.1.15)

gx.scores: Function to Compute Scores on the Basis of Threshold Estimates

Description

Computes scores for a user selected group of variables based on the ratio of variable value to the variable threshold, i.e. the upper limit of background variation. The user must provide thresholds for the variables contributing to the scores. Optionally a set of relative weights may be provided that are applied to the scores. If above threshold values occur for a variable whose influence is indicative of a ‘false’ anomaly the relative weight for that variable may be set ‘-ve’, which will result in a reduction of the computed score. This function is a useful alternative to weighted sums when the variable data contains so many below DL values that summary statistics cannot be estimated. An object is created containing all the provided parameters and the scores for later reference and use.

Usage

gx.scores(xx, tholds, rwts = NULL, setna = FALSE)

Arguments

xx

name of the n by p matrix containing the data.

tholds

a vector of the threshold estimates for the p variables.

rwts

an optional vector of the relative weights for the p variables, negative weights are permisable to indicate that high levels of the variable should have a negative impact on the scores.

setna

if it is required to set any ‘<=0’ scores to NAs then set setna = TRUE. See note below.

Value

The following are returned as an object to be saved for further use:

input

the name of the input data set

tholds

the vector of thresholds used for the computations

rwts

the vector of relative weights provided by the user

scores

the computed scores

Details

If the data for only some of the variables available in an attached matrix or data frame are to be processed use the cbind construct. Thus, temp.mat <- cbind(vname1, vname3, vname6, vname8), or the cbind may be used directly, see Example below. All computed scores with values less that 1 are set to zero, optionally these may be replaced by NAs to facilitate their removal from subsequent plots, see Note below.

See Also

ltdl.fix.df, remove.na

Examples

Run this code
# NOT RUN {
##  Make test data available
data(sind)
attach(sind)

##  Compute scores - 1
sind.scores1 <- gx.scores(cbind(Cu, Zn, Cd), tholds = c(100, 200, 2))
map.z(E, N, sind.scores1$scores)

##  Compute scores - 2
sind.scores2 <- gx.scores(cbind(Cu, Zn, Cd, Fe), tholds = c(100, 200, 2, 2),
	rwts = c(1, 1, 1, -1))
xyplot.z(Fe, Mn, sind.scores2$scores, col = 2)

## Clean up and detach test data
rm(sind.scores1)
rm(sind.scores2)
detach(sind)
# }

Run the code above in your browser using DataLab