trim: Trim the Binning Tree

Description Usage Arguments Value Examples

Description

Given a treebinr object, trim removes all leaves with measure values less than one specified by the user

Usage

1
2
trim(val, treebinr_obj, getMeasure = function(bin, inputs) {     bin@measure
  }, binMeasure, makePoint, updateBin, inputs = NULL)

Arguments

val

The largest value of measure to be removed

treebinr_obj

An object of class treebinr

getMeasure

A user supplied function to compute the measure to be compared between bins. By default, returns whatever value is in the measure slot of the bin object.

binMeasure

A user supplied function to compute the measure associated with each bin

makePoint

A user supplied function to turn the contents of a bin into a single point

updateBin

A user supplied function combine several bins into a single bin

inputs

A list containing additional input parameters required by user supplied functions

Value

The return value is an object of class treebinr, which contains the following

points

A matrix containing the reduced point configuration

counts

A vector containing the number of points in each bin

bins

A list containing bin objects, which detail the contents of each bin

tree

An undirected graph object for the binning tree

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
#Bin a Normal Configuration to 500 Points
set.seed(1337)
X <- matrix(rnorm(2000),ncol=2)

numbins <- 500
nCols <- ncol(X)
binMeasure <- gapMeasure
selectBin <- gapSelect
splitBin <- gapSplit
boundaryTest <- gapBoundaryTest
makePoint <- gapPoints

inputs <- list(dimRange = sapply(1:nCols, FUN = function(j) {range(X[,j])}), binsperdim = 10)
binInfo <- list(binRange = sapply(1:nCols, FUN = function(j) {range(X[,j])}))

treebin_obj <- treebin(X, numbins, binMeasure, boundaryTest, selectBin, splitBin, makePoint, binInfo, inputs)

#Trim all values of measure less than 0.01
val <- .01
updateBin <- gapUpdate
getMeasure <- function(bin, inputs){
  max <- max(bin@measure)
  return(max)
}

out <- trim(val, treebin_obj, getMeasure, binMeasure, makePoint, updateBin, inputs)

rwoldford/treebinr documentation built on May 12, 2019, 4:38 a.m.