lra-ord {ordr} | R Documentation |
Log-ratio analysis
Description
Represent log-ratios between variables based on their values on a population of cases.
Usage
lra(x, compositional = FALSE, weighted = TRUE)
## S3 method for class 'lra'
print(x, nd = length(x$sv), n = 6L, ...)
## S3 method for class 'lra'
screeplot(x, main = deparse1(substitute(x)), ...)
## S3 method for class 'lra'
biplot(
x,
choices = c(1L, 2L),
scale = c(0, 0),
main = deparse1(substitute(x)),
var.axes = FALSE,
...
)
## S3 method for class 'lra'
plot(x, main = deparse1(substitute(x)), ...)
Arguments
x |
A numeric matrix or rectangular data set. |
compositional |
Logical; whether to normalize rows of |
weighted |
Logical; whether to weight rows and columns by their sums. |
nd |
Integer; number of shared dimensions to include in print. |
n |
Integer; number of rows of each factor to print. |
main , var.axes , ... |
Parameters passed to other plotting methods (in the
case of |
choices |
Integer; length-2 vector specifying the components to plot. |
scale |
Numeric; values between 0 and 1 that control how inertia is
conferred unto the points: Row ( |
Details
Log-ratio analysis (LRA) is based on a double-centering of log-transformed data, usually weighted by row and column totals. The technique is suitable for positive-valued variables on a common scale (e.g. percentages). The distances between variables' coordinates (in the full-dimensional space) are their pairwise log-ratios. The distances between cases' coordinates are called their log-ratio distances, and the total variance is the weighted sum of their squares.
LRA is not implemented in standard R distributions but is a useful member of the ordination toolkit. This is a minimal implementation following Greenacre's (2010) exposition in Chapter 7.
Value
Given an n * p
data matrix and setting r=min(n,p)
,
lra()
returns a list of class "lra"
containing three elements:
svThe
r-1
singular valuesrow.coordsThe
n * (r-1)
matrix of row standard coordinates.column.coordsThe
p * (r-1)
matrix of column standard coordinates.row.weightsThe weights used to scale the row coordinates.
column.weightsThe weights used to scale the column coordinates.
References
Greenacre MJ (2010) Biplots in Practice. Fundacion BBVA, ISBN: 978-84-923846. https://www.fbbva.es/microsite/multivariate-statistics/biplots.html
Examples
# U.S. 1973 violent crime arrests
head(USArrests)
# row and column subsets
state_examples <- c("Hawaii", "Mississippi", "North Dakota")
arrests <- c(1L, 2L, 4L)
# pairwise log-ratios of violent crime arrests for two states
arrest_pairs <- combn(arrests, 2L)
arrest_ratios <-
USArrests[, arrest_pairs[1L, ]] / USArrests[, arrest_pairs[2L, ]]
colnames(arrest_ratios) <- paste(
colnames(USArrests)[arrest_pairs[1L, ]], "/",
colnames(USArrests)[arrest_pairs[2L, ]], sep = ""
)
arrest_logratios <- log(arrest_ratios)
arrest_logratios[state_examples, ]
# non-compositional log-ratio analysis
(arrests_lra <- lra(USArrests[, arrests]))
screeplot(arrests_lra)
biplot(arrests_lra, scale = c(1, 0))
# compositional log-ratio analysis
(arrests_lra <- lra(USArrests[, arrests], compositional = TRUE))
biplot(arrests_lra, scale = c(1, 0))