wtd.sums: Function to Compute Weighted Sums

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

Description

Computes weighted sums for a user selected group of variables (Garrett et al., 1980; Garrett and Grunsky, 2001). The user must provide the relative importances of the the variables contributing to the weighted sums. By default the median and MAD are estimated as measures of location and spread for the data. These may be replaced with alternate estimates if the user wishes, see Details below. An object is created containing all the estimated parameters and the weighted sums for later reference and use.

Usage

1
wtd.sums(xx, ri, xloc = NULL, xspread = NULL)

Arguments

xx

name of the n by p matrix containing the data.

ri

a 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 weighted sums.

xloc

the default procedure is to use the computed medians of the input variables. Alternately, a vector of p estimates of location may be provided.

xspread

the default procedure is to use the computed MADs of the input variables. Alternately, a vector of p estimates of spread may be provided.

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.

Value

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

input

the name of the input data set

xloc

the vector of locations used for the computations

xspread

the vector of spreads used for the computations

ri

the vector of relative importances provided by the user

w

the vector of weights computed from the relative importances

a

the vector of coefficients - the normalized weights

ws

the computed weighted sums

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 prior to executing this function, see ltdl.fix.df.

Any rows in the data matrix with with NAs are removed prior to computing the weighted sums.

Author(s)

Robert G. Garrett

References

Garrett, R.G. and Grunsky, E.G., 2001. Weighted Sums - Knowledge based empirical indices for use in exploration geochemistry. Geochemistry: Exploration, Environment and Analysis, 1(2):135-141.

Garrett, R.G, Kane, V.E. and Zeigler, R.K., 1980. The management and analysis of regional geochemical data. Journal of Geochemical Exploration, 13(1/2):115-152.

See Also

ltdl.fix.df, remove.na

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
##  Make test data available
data(sind)
attach(sind)

##  Compute weighted sums as in Garrett & Grunsky (2001)
##  using medians and interquartile SDs
sind.ws.geea <- wtd.sums(cbind(Zn, Cd, Fe, Mn), ri = c(2, 1, -1, -1),
	xloc = c(48, 0.6, 1.74, 590), 
	xspread = c(41.5128, 0.44478, 0.882147, 333.585))

## Compute weighted sums using the median and MAD defaults
sind.ws.def <- wtd.sums(cbind(Zn, Cd, Fe, Mn), ri = c(2, 1, -1, -1))

## Plot the two results against one-another, adding a constant,
## 3, to the weighted sums to make them positive and log-scale
## plottable
par(pty="s")
plot(sind.ws.geea$ws+3, sind.ws.def$ws+3, log = "xy", 
	xlim = c(2, 28), ylim = c(2, 28))
abline(0, 1, lty = 3)
abline(v =3, lty = 3)
abline(h = 3, lty = 3)

## Inspect the default weighted sums, adding a constant, 3, to the
## weighted sums to make them positive and log-scale plottable
shape(sind.ws.def$ws+3, log = TRUE)

## Plot EDA Tukey boxplot based map of default weighted sums
map.eda7(E, N, sind.ws.def$ws)

## Clean-up and detach test data
rm(sind.ws.geea)
rm(sind.ws.def)
par(pty = "m")
detach(sind)

Example output

Loading required package: MASS
Loading required package: fastICA
Warning messages:
1: In par(old.par) : graphical parameter "cin" cannot be set
2: In par(old.par) : graphical parameter "cra" cannot be set
3: In par(old.par) : graphical parameter "csi" cannot be set
4: In par(old.par) : graphical parameter "cxy" cannot be set
5: In par(old.par) : graphical parameter "din" cannot be set
6: In par(old.par) : graphical parameter "page" cannot be set

	Cut Levels	  No. of Symbols   Symbol - size - Colour
	Log = FALSE 				sfact = 1.00 

			       2 	     Circle  2.00    25 
	 -1.26 
			       1 	     Circle  1.50    22 
	 -0.74 
			       4 	     Circle  1.00    20 
	 -0.21 
			       12 	     Cross   0.50    13 
	 0.14 
			       1 	     Square  1.00    6 
	 0.67 
			       1 	     Square  1.50    4 
	 1.19 
			       4 	     Square  2.00    1 
Warning messages:
1: In par(old.par) : graphical parameter "cin" cannot be set
2: In par(old.par) : graphical parameter "cra" cannot be set
3: In par(old.par) : graphical parameter "csi" cannot be set
4: In par(old.par) : graphical parameter "cxy" cannot be set
5: In par(old.par) : graphical parameter "din" cannot be set
6: In par(old.par) : graphical parameter "page" cannot be set

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

Related to wtd.sums in rgr...