select.axes: Selects ordination axes

View source: R/select.axes.R

select.axesR Documentation

Selects ordination axes

Description

Selects the axes required to explain a cumulative threshold amount of variance in an ordination (e.g. > 95%).

Usage

select.axes(data, group, threshold = 0.95, inc.threshold = TRUE)

Arguments

data

The trait space to analyse. This can be either a "matrix", "prcomp", "princomp" or a "dispRity" object.

group

Optional, either a list of row numbers or names to be used as different groups or a data.frame with the same k elements as in data as rownames. If data is a "dispRity" object that already contains groups, the group argument is recycled.

threshold

The arbitrary threshold amount of variance (by default this is 0.95).

inc.threshold

Logical, whether to output the axes that contain the threshold value (TRUE; default) or not (FALSE). See details.

, i.e. the axes necessary to include at least the threshold value

Details

If inc.threshold = TRUE, the returned axes are the ones that contains at least the threshold value (e.g. if the threshold is 0.95, all the returned axes contain at least 0.95 of the variance, potentially more). If inc.threshold = FALSE, the returned axes are the ones before reaching this threshold (e.g. the cumulative variance returned is strictly less or equal to 0.95).

Value

A "dispRity", "axes" object that can be printed, summarised and plot through generic print, summary and plot functions. The object is a list containing:

  • $dimensions: the maximum number of dimensions selected across all groups;

  • $dim.list: the selected dimensions per group;

  • $var: the variance per axes per group;

  • $scaled.var: the variance scaled variance per axes per group;

  • $cumsum.var: the cumulative scaled variance per axes per group;

  • $call: a list containing the $threshold value and the $inc.threshold option used.

Author(s)

Thomas Guillerme

See Also

custom.subsets

Examples

## Ordinating the USArrests dataset
ordination <- princomp(USArrests, cor = TRUE)
## Which dimensions to select?
(selected <- select.axes(ordination))
## The selected dimensions
selected$dimensions
## Visualising the results
plot(selected)

## Same but by grouping the data into three groups
states_groups <- list("Group1" = c("Mississippi","North Carolina",
                                   "South Carolina", "Georgia", "Alabama",
                                   "Alaska", "Tennessee", "Louisiana"),
                      "Group2" = c("Florida", "New Mexico", "Michigan",
                                   "Indiana", "Virginia", "Wyoming", "Montana",
                                   "Maine", "Idaho", "New Hampshire", "Iowa"),
                      "Group3" = c("Rhode Island", "New Jersey", "Hawaii",
                                   "Massachusetts"))
(selected <- select.axes(ordination, group = states_groups))
## Note that the required number of axes is now 4 (instead of 3)
plot(selected)

## Loading some example dispRity data
data(demo_data)
## How many axes are required to explain 99% of the variance
## for each group in the Healy et al 2019 data?
(how_many <- select.axes(demo_data$healy, threshold = 0.99))
summary(how_many)
plot(how_many)



TGuillerme/dispRity documentation built on Dec. 21, 2024, 4:05 a.m.