DivideM {lazy.tree}R Documentation

Divide a set of objects into two homogeneous sets with resampling

Description

This function searches the average division of a given subset by resmpling the subset.
Japanese help file: DivideM_JPH

Usage

DivideM(
  ys,
  Xs,
  Ys = NULL,
  impfunc,
  S,
  method = 1,
  ncatx = 0,
  app = 0,
  maxapp = 10,
  maxncut = 50,
  levelsy = NULL,
  levelsX = NULL,
  majestic = 3,
  nrepM = 50,
  psampleM = 100,
  rf = 1,
  nxvarM = if (!is.null(ys) && !is.factor(ys)) max(floor(ncol(Xs)/3), 1) else
    floor(sqrt(ncol(Xs))),
  minLeftM = 0.5,
  maxRightM = 0.5,
  r = 0,
  debug = 0
)

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.

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

majestic

> 0 to use within node resampling:
= 1 to use modal splitting variable
= 2 to use binary LR to determine J and predict ys from J
= 3 to use binary LR to determine J
= 4 to use continuous LR
= 5 to use logit of continuous LR

nrepM

# of divisions to try for majestic tree

psampleM

percentage of the sample for majestic tree

rf

= 0 not to sample regressor variables

nxvarM

# of variables to sample for majestic tree (Random Forest)

minLeftM

minimum proportion of x values to be classified as Left

maxRightM

maximum proportion of x values to be classified as Right

r

node number

debug

= 1 to print intermediate result

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
valxj: the set of values of nominal variable j to be classified as left.
       Note that this is a numeric variable, not a factor.
k:     quantified variable number used or 0
nqx:   # of unique quantified variables
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


N=500
Xc=data.frame(x1=as.factor(square3$x1), x2=square3$x2)
yc=as.factor(square3$y)
Xc=Xc[1:N,]
yc=yc[1:N]
S=1:N
maxncatx=max( apply( Xc, 2, function(x){length(unique(x))} ) )

ncaty=length(levels(yc))

  id=gen01pat( ncaty, sort=-2, partition=1 ) == 1  # logical matrix
  npart=nrow(id)
  uy=unique(yc)
  Yc=matrix(0,N,npart)
  for(k in 1:npart ){
    Yc[,k]=yc %in% uy[id[k,]]
  }

  nx=ncol(Xc)
  ncatx=rep(0,nx)
  for( j in 1:nx ){
    if( is.factor(Xc[,j]) ) ncatx[j]=length(levels(Xc[,j]))
  }

res00=DivideM( yc, Xc, Y=Yc, impfunc=entropy, S, method=1, ncatx=ncatx
              , app=0, maxapp=10, maxncut=50
              , levelsy=NULL, levelsX=NULL
              , psampleM=100, nrepM=20, r=0 )



[Package lazy.tree version 0.1.6 ]