Learn R Programming

hypervolume (version 3.1.4)

hypervolume_n_occupancy_test: Significance of random points occupancy

Description

The function hypervolume_n_occupancy_test() calculates the significance of the difference between occupancy values for each random point and for all the pairwise combinations of groups in objects generated with hypervolume_n_occupancy() and hypervolume_n_occupancy_permute().

Usage

hypervolume_n_occupancy_test(observed,
                             path,
                             alternative = "two_sided",
                             significance = 0.05,
                             cores = 1, 
                             p_adjust = "none",
                             multi_comp_type = "pairwise")

Value

An HypervolumeList of length equal to the number of pairwise combinations of the observed HypervolumeList elements. ValueAtRandomPoints are calculated as the difference between the ValueAtRandomPoints of the first and the second group for each pairwise combination. Only significant values are retained according to significance.

Arguments

observed

An HypervolumeList generated from hypervolume_n_occupancy().

path

A path to a directory of permuted hypervolumes generated with hypervolume_n_occupancy_permute().

alternative

Alternative hypothesis, can be one of two_sided, more or less.

significance

Significance values lower than this threshold will be retained.

cores

Number of logical cores to use while generating permuted hypervolumes. If parallel backend already registered to doParallel, function will use that backend and ignore the argument in cores.

p_adjust

Method of correction for multiple comparisons, set to none by default. Otherwise look at p.adjust of the stats package for alternatives.

multi_comp_type

Type of multiple comparison. Can be pairwise, for which the number of comparisons is set to the length of ValueAtRandomPoints, all, for which the number of comparisons is set to the length of ValueAtRandomPoints times the number of groups, or none.

Details

The observed difference between ValueAtRandomPoints of two groups is compared against null expectations generated with hypervolume_n_occupancy_permute().

Examples

Run this code
if (FALSE) {
data(penguins,package='palmerpenguins')
penguins_no_na = as.data.frame(na.omit(penguins))


# split the dataset on species and sex
penguins_no_na_split = split(penguins_no_na, 
                        paste(penguins_no_na$species, penguins_no_na$sex, sep = "_"))


# calculate the hypervolume for each element of the splitted dataset
hv_list = mapply(function(x, y) 
  hypervolume_gaussian(x[, c("bill_length_mm", "flipper_length_mm")],
                       samples.per.point=100, name = y), 
  x = penguins_no_na_split, 
  y = names(penguins_no_na_split))

names(hv_list) <- names(penguins_no_na_split)
hv_list <- hypervolume_join(hv_list)


hv_occupancy_list_sex <- hypervolume_n_occupancy(hv_list, 
                              classification = rep(c("female", "male"), each = 3))

# takes 9 permutations on 1 core
hyper_permuted <- hypervolume_n_occupancy_permute("permute", hv_occupancy_list_sex,
                                hv_list , n = 99, cores = 1)

hypervolume_test <- hypervolume_n_occupancy_test(hv_occupancy_list_sex, hyper_permuted, 
                      alternative = "more", significance = 0.1)


}

Run the code above in your browser using DataLab