Divide {lazy.tree}R Documentation

Divide a set of objects into two homogeneous sets

Description

This function divides a given set of objects into two subsets so that the weighted sum of the impurity measures of the subsets are minimized using a greedy algorithm with Depth-First Search (DFS).
Japanese help file: Divide_JPH

Usage

Divide(
  ys,
  Xs,
  Ys = NULL,
  impfunc,
  S,
  method = 1,
  ncatx = 0,
  app = 0,
  maxapp = 10,
  maxncut = 50,
  levelsy = NULL,
  levelsX = NULL
)

Arguments

ys

Criterion variable vector

Xs

Regressor matrix

Ys

The dichotomized criterion matrix for method=4

impfunc

impurity function

S

Index vector indicating the original location of the rows of ys and X.
(ys, Xs, Ys, S) have the same # of rows or of the same length.

method

Treatment of the categorical regressor variable.
= 0 to dummy expand the categorical regressor,
= 1 to use the first canonical varialbe,
= 2 to use up to the 2nd canonical variables and their sum and difference,
= 3 to use one-versus-rest dichotomization.
= 4 to use dichotomization of the criterion variable on the basis of all possible bipartitions of the levels of the criterion variable.

ncatx

Vector consisting of the # of cagegories of the regressors

app

= 0 not to use app (all possible partitions)
= 1 to use app when ncaty >= 3 and ncatx >= 3
= 9 to use app awlays for categorical predictors.

maxapp

Maximum # of categories of the regressor variables for which app is used.

maxncut

Maximum # of cut point (threshold) candidate

levelsy

# of levels of the criterion

levelsx

a list of the # of levels of the regressors

Details

ncat=0 or ncat=1 means the variable is continuous,
ncat=2 means the variable is binary,
ncat >= 3 means the variable is polytomous.

Value

A list consisting of the following:

j:         the variable number used to divide the set
threshold: the threshold of variable j when it is continuous, or NA.
valxj: the set of values of nominal variable j to be classified as left
valxjR: the set of values of nominal variable j to be classified as right
       Note that these are numeric variables, not factors.
k:     quantified variable number used or 0
nqx:   # of unique quantified variables
locLL and locRR: the location of obs in 1:nrow(Xs) to be classficed
left:  the set of observations classified as left
right: the set of observations classified as right
left.score:  The nobs weighted impurity measure of left set
right.score: The nobs weighted impurity measure of right set
score:       The sum of the above two.

Examples

Xc <- data.frame(x1=as.factor(square$x1),x2=as.factor(square$x2))
Divide( square$Class4, Xc, impfunc=gini, S=1:nrow(Xc), method=1
      , ncatx=c(7,5), app=0 )
Divide( square$Class4, Xc, impfunc=gini, S=1:nrow(Xc), app=9
      , ncatx=c(7,5) )



[Package lazy.tree version 0.1.6 ]