hypervolume_general_model: Generates hypervolume by sampling from arbitrary model...

View source: R/hypervolume_general_model.R

hypervolume_general_modelR Documentation

Generates hypervolume by sampling from arbitrary model object.

Description

Uses rejection sampling to obtain predicted values of a model object at uniformly random points within a range box, then converts output to a hypervolume.

Usage

hypervolume_general_model(model, name = NULL, verbose = TRUE, 
  data = NULL, range.box = NULL, num.samples = ceiling(10^(3 + sqrt(ncol(range.box)))), 
  chunk.size = 10000, min.value = 0, ...)

Arguments

model

Any model object which can be used within a predict(model, newdata, ...) call.

name

Name of the output hypervolume

verbose

If TRUE, prints diagnostic output.

data

If not NULL, used to specify range.box=padded_range(data).

range.box

A 2 x n matrix, where n is the number of dimensions of the data, and the first row corresponds to a lower limit and the second row to an upper limit. Each column is thus the low and high limits of the range box along each axis. Can be generated via padded_range.

num.samples

Number of samples to draw from the range box.

chunk.size

Number of samples to process in each predict call. Changing this value may affect the speed of function return but not the returned values.

min.value

If TRUE, discards sampled values below this threshold. Effectively used to set hypervolume boundaries.

...

Other arguments to be passed to predict, e.g. type='response'.

Value

A Hypervolume-class object corresponding to retained values within the hyperbox of interest.

Examples

data(penguins,package='palmerpenguins')
penguins_no_na = as.data.frame(na.omit(penguins))
penguins_no_na$is_adelie = penguins_no_na$species=="Adelie"
penguins_no_na = penguins_no_na[,c("is_adelie","bill_length_mm","bill_depth_mm")]


m_glm = glm(is_adelie~.,data=penguins_no_na)

hv_general_glm = hypervolume_general_model(m_glm, 
  range.box=padded_range(penguins_no_na[,2:3]),type='response')
plot(hv_general_glm)	
	

bblonder/hypervolume documentation built on Feb. 1, 2024, 8:01 p.m.