Learn R Programming

rgr (version 1.1.0)

gx.2dproj: Function to Compute and Display 2-d Projections for Data Matrices

Description

Function computes and displays 2-d projections of data matrices using either Sammon Non-linear Mapping (default) or Multidimensional Scaling. The original S-Plus implementation also computed the Minimum Spanning Tree plane projection (Friedman and Rafsky, 1981). All three functionalities were availble in the Venables and Ripley MASS library for S-Plus. However, the R implememntation of the MASS library does not include Minimum Spanning Trees.

Usage

gx.2dproj(xx, proc = "sam", log = FALSE, rsnd = FALSE, snd = FALSE,
	range = FALSE, main = "", ...)

Arguments

xx
the n by p matrix for which the 2-d projection is required.
proc
the 2-d projection procedure required, the default is proc = "sam" for Sammon Non-linear Mapping. For Multidimensional Scaling use proc = "mds".
log
optional (natural) log transformation of the data, the default is no log transformation. For a log transformation set log = TRUE.
rsnd
optional robust normalization of the data with matrix column medians and MADs, the default is no transformation. For a robust normalization set rsnd = TRUE.
snd
optional normalization of the data with matrix column means and standard deviations, the default is no transformation. For a normalization set snd = TRUE. If rsnd = TRUE, then snd will be set to FALSE.
range
optional range transformation for the matrix columns, the data values being scaled to between zero and one for, respectively, the minimum and maximum column values. If the data are range transformed, other normalization transformation requests will be ig
main
an alternative plot title, see Details below.
...
further arguments to be passed to methods concerning the generated plots. For example, if smaller plotting characters are required, specify cex = 0.8; or if some colour other than black is required for the plotting characters, specify

Value

  • The following are returned as an object to be saved for further use:
  • mainthe plot title.
  • usagea text string containing the name of the n by p matrix containing the data, the projection option, the values, TRUE or FALSE, for the log, robust normalization, normalization, and rangetransformation options.
  • xlabthe 2-d projection x-axis label.
  • ylabthe 2-d projection y-axis label.
  • matnamesthe names of the input variables and row numbers. Note if an ilr transform has been used the variable names will be the (p-1) synthetic ilr variable names.
  • xthe n x-axis values for the 2-d projection.
  • xthe n y-axis values for the 2-d projection.
  • stressthe estimated stress of fitting 2-d projection to the p-space data.

Details

If main is undefined a default plot title is generated by appending the input matrix name to the text string "2-d Projection for: ". If no plot title is required set main = "", or if a user defined plot title is required it should be defined in main, e.g., main = "Plot Title Text". It is desirable to normalize, centre and scale, or undertake a range transformation on the data. If no transformation is requested a warning message is displayed. For closed compositional data sets an ilr transformation is recommended, which can be done in the function call, see the Example below. This also has the effect of reducing the dimension of the data matrix from p to (p-1). The x- and y-axis labels are set appropriately to indicated the type of 2-d projection in the display. A measure of the stress in generating the 2-d projection is estimated and displayed, low stress indicates the projection faithfully represents the relative positions of the data in the original p-space.

References

Friedman, J.H. and Rafsky, L.C., 1981. Graphics for the multivariate two-sample problem. Journal of the American Statistical Association, 76(374):277-291. 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. Venables, W.N. and Ripley, B.D., 2001. Modern Applied Statistics with S-Plus, 3rd Edition, Springer, 501 p.

See Also

ltdl.fix.df, remove.na, gx.2dproj.plot

Examples

Run this code
## Make test data available
data(sind)
sind.mat <- as.matrix(sind[, -c(1:3)])
## Ensure all data are in the same units (mg/kg)
sind.mat2open <- sind.mat
sind.mat2open[, 2] <- sind.mat2open[, 2] * 10000

## Display default 2-d Projection
sind.save <- gx.2dproj(ilr(sind.mat2open))

## Display saved object identifying input matrix row numbers (cex = 0.7),
## and with an alternate main title (cex.main = 0.8) 
gx.2dproj.plot(sind.save, idplot = TRUE, cex = 0.7, 
	main = "Howarth & Sinding-Larsen
Stream Sediment ilr Transformed Data",	cex.main = 0.8)

## Clean-up
rm(sind.mat)
rm(sind.mat2open)
rm(sind.save)

Run the code above in your browser using DataLab