Learn R Programming

PrInDT (version 2.0.1)

SimCPrInDT: Interdependent estimation for classification

Description

The function SimCPrInDT applies interdependent estimation (endogenous case) for finding an optimal model for relationships between the two-class factor variables specified as column indices of 'data' in the vector 'inddep' and all other factor and numerical variables in the data frame 'data' by means of 'N' repetitions of random subsampling with percentages 'percl' for the large classes and 'percs' for the small classes. One percentage of observations for each dependent variable has to be specified for the larger and the smaller class. For example, for three dependent variables, 'percl' consists of three percentages specified in the order in which the dependent variables appear in 'inddep'.
The dependent variables have to be specified as dummies, i.e. as 'property absent' (value 0) or 'property present' (value 1).
The optimization citerion is the balanced accuracy on the full sample.
In an additional step, the mean balanced accuracy over all class variables is optimized (joint optimization).
The trees generated from undersampling can be restricted by not accepting trees including split results specified in the character strings of the vector 'ctestv'.
The parameters 'conf.level', 'minsplit', and 'minbucket' can be used to control the size of the trees.

Usage

SimCPrInDT(data,ctestv=NA,inddep,percl,percs,N=99,M,psize,conf.level=0.95,
                                  minsplit=NA,minbucket=NA)

Value

models1

Best trees at stage 1

models2

Best trees at stage 2

models3

Best trees from mean maximization

classnames

names of classification variables

baAll

balanced accuracies of best trees at both stages

Arguments

data

Input data frame with class factor variables and the influential variables,
which need to be factors or numericals (transform logicals and character variables to factors)

ctestv

Vector of character strings of forbidden split results;
Example: ctestv <- rbind('variable1 == {value1, value2}','variable2 <= value3'), where character strings specified in 'value1', 'value2' are not allowed as results of a splitting operation in variable 1 in a tree.
For restrictions of the type 'variable <= xxx', all split results in a tree are excluded with 'variable <= yyy' and yyy <= xxx.
Trees with split results specified in 'ctestv' are not accepted during optimization.
A concrete example is: 'ctestv <- rbind('ETH == {C2a, C1a}','AGE <= 20')' for variables 'ETH' and 'AGE' and values 'C2a','C1a', and '20';
If no restrictions exist, the default = NA is used.

inddep

indices of dependent variables

percl

list of undersampling percentages of larger class (numerical, > 0 and <= 1): one per dependent class variable in the same order as in 'inddep'

percs

list of undersampling percentage of smaller class (numerical, > 0 and <= 1); one per dependent class variable in the same order as in 'inddep'

N

no. of repetitions of subsampling of observations (integer > 0); default = 99

M

no. of repetitions of subsampling of predictors

psize

no. of predictors in the subsamples of the predictors

conf.level

(1 - significance level) in function ctree (numerical, > 0 and <= 1);
default = 0.95

minsplit

Minimum number of elements in a node to be splitted;
default = 20

minbucket

Minimum number of elements in a node;
default = 7

Details

See Buschfeld & Weihs (2025), Optimizing decision trees for the analysis of World Englishes and sociolinguistic data. Cambridge University Press, section 4.5.6.2, for further information.

Standard output can be produced by means of print(name) or just name as well as plot(name) where 'name' is the output data frame of the function.

Examples

Run this code
data <- PrInDT::data_land # load data
dataclean <- data[,c(1:7,23:24,11:13,22,8:10)]  # only relevant features
inddep <- c(14:16) # dependent variables
dataland <- na.omit(dataclean)
ctestv <- NA
perc <- c(0.45,0.05,0.25)   # percentages of observations of larger class, 
# 1 per dependent class variable
perc2 <- c(0.75,0.95,0.75)  # percentages of observations of smaller class, 
# 1 per dependent class variable
outland <- SimCPrInDT(dataland,percl=perc,percs=perc2,N=9,inddep=inddep,M=2,psize=10)
outland
plot(outland)

Run the code above in your browser using DataLab