hypervolume_resample: Hypervolume resampling methods

Description Usage Arguments Details Value See Also Examples

View source: R/hypervolume_resample.R

Description

hypervolume_resample generates new hyperolumes based on the method input. Outputs written to file.

- "bootstrap": Generates n hypervolumes using data bootstrapped from original data

- "bootstrap seq": Generates n hypervolumes for each sample size in sequence specified by user

- "biased bootstrap": Bootstraps input hypervolume with biases applied through multivariate normal weights or user specified weights

- "k_split": Generates k hypervolumes while leaving out disjoint sets with size 1/k of total points each time

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
hypervolume_resample(name, 
                      hv, 
                      method, 
                      n = 10, 
                      points_per_resample = "sample_size", 
                      seq = 3:nrow(hv@Data), 
                      k = 5, 
                      cores = 1,
                      verbose = TRUE, 
                      mu = NULL, 
                      sigma = NULL, 
                      cols_to_bias = 1:ncol(hv@Data), 
                      weight_func = NULL)

Arguments

name

File name; The function writes hypervolumes to file in ./Objects/<name>

hv

A hypervolume object

method

String input; options are "bootstrap", "bootstrap seq", "biased bootstrap", and "k_split"

n

Number of resamples to take. Used for every method.

points_per_resample

Number of points in each resample. If the input is "sample_size", then the same number of points as the original sample is used. Used for method = "bootstrap" and method = "biased bootstrap".

seq

Sequence of sample sizes. If method = "bootstrap seq" then the function generates n bootstrapped hypervolumes for each sample size in seq. Used for method = "bootstrap seq".

k

Number of splits. Used for method = "k_split"

cores

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

verbose

Logical value; If function is being run sequentially, outputs progress bar in console.

mu

Array of values specifying the mean of multivariate normal weights. Used for method = "biased bootstrap".

sigma

Array of values specifying the variance in each dimension. (Lower variance corresponds to stronger bias) Used for method = "biased bootstrap".

cols_to_bias

Array of column indices; must be same length as mu and sigma. Used for method = "biased bootstrap".

weight_func

Custom weight function that takes in a matrix of values and returns desired weights for each row Used for method = "biased bootstrap".

Details

hypervolume_resample creates a directory called Objects in the current working directory if a directory of that name doesn't already exist. Returns an absolute path to directory with resampled hypervolumes. rds files are stored in different file structures depending on which method is called.

Use to_hv_list to extract every hypervolume object in a directory into a HypervolumeList object. It is also possible to access the hypervolumes by using readRDS to read the hypervolume objects in one by one.

The resampled hypervolumes are generated using the same parameters used to generate the input hypervolume. The only exception is if the method for generating the input hypervolume is "gaussian" (the default), then bandwidth isn't preserved for different sampe sizes.

Value

returns a string containing an absolute path equivalent to ./Objects/<name>

See Also

to_hv_list, hypervolume_overlap_test, hypervolume_funnel, hypervolume_overlap_confidence

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
## Not run: 
data(iris)
hv = hypervolume(iris[,c(1,2)])

# Example 1
# Use detectCores to see how many cores are availible in current environment
# Get rid of cores argument or set cores = 1 to run sequentially
path = hypervolume_resample("example_bootstrap", 
                              hv, 
                              method = "bootstrap", 
                              n = 50, 
                              cores = 12)
hvs = to_hv_list(path)

# Example 2
# Get maximum sepal length
max_sepal = max(iris$Sepal.Length)
# Make data with larger sepal size slightly more likley to be resampled
biased_path = hypervolume_resample("biased test", 
                                    hv, 
                                    method = "biased bootstrap", 
                                    n = 50, 
                                    cores = 12, 
                                    mu = max_sepal, 
                                    sigma = 30, 
                                    cols_to_bias = "Sepal.Length")
hvs_based = to_hv_list(biased_path)

## End(Not run)

dc165/Hypervolume-Dev documentation built on Dec. 13, 2020, 6:02 p.m.