Learn R Programming

PrInDT (version 2.0.1)

PrInDTreg: Regression tree resampling by the PrInDT method

Description

The function PrInDTreg realizes regression tree optimization to identify the best interpretable tree; interpretability is checked (see 'ctestv').
The relationship between the target variable 'regname' and all other factor and numerical variables in the data frame 'datain' is optimally modeled by means of 'N' repetitions of subsampling.
The optimization criterion is the R2 of the model on the validation sample 'valdat'.
Default for the validation sample is the full sample 'datain'.
Multiple subsampling percentages of observations and predictors can be specified (in 'pobs' and 'ppre', correspondingly).
The trees generated from subsampling can be restricted by rejecting unacceptable trees which include 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.
Besides the maximal R2, the minimal MAE (Mean Absolute Error) is reported.

Usage

PrInDTreg(datain,regname,ctestv=NA,N,pobs=c(0.9,0.7),ppre=c(0.9,0.7),
               conf.level=0.95,seedl=TRUE,minsplit=NA,minbucket=NA,valdat=datain)

Value

meanint

Mean number of interpretable trees over the combinations of individual percentages in 'pobs' and 'ppre'

ctmax

best resampled regression tree on the validation data set

percmax

Best model achieved for %observations

perfeamax

Best model achieved for %predictors

maxR2

maximum R2 on the validation data set for resampled regression trees (for 'ctmax')

minMAE

minimum MAE (Mean Absolute Error) on the validation data set for resampled regression trees (for 'ctmax')

interpmax

interpretability of best tree 'ctmax'

ctmax2

second best resampled regression tree on the full data set

percmax2

second best model achieved for %observations

perfeamax2

second best model achieved for %features

max2R2

second best R2 on the validation data set for resampled regression trees (for 'ctmax2')

min2MAE

second best MAE on the validation data set for resampled regression trees (for 'ctmax2')

interp2max

interpretability of second-best tree 'ctmax2'

Arguments

datain

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

regname

name of regressand variable (character)

ctestv

Vector of character strings of forbidden split results;
(see function PrInDT for details.)
If no restrictions exist, the default = NA is used.

N

Number of repetitions (integer > 0)

pobs

Vector of resampling percentages of observations (numerical, > 0 and <= 1)

ppre

Vector of resampling percentages of predictor variables (numerical, > 0 and <= 1)

conf.level

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

seedl

Should the seed for random numbers be set (TRUE / FALSE)?
default = TRUE

minsplit

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

minbucket

Minimum number of elements in a node;
default = 7

valdat

Validation data; default = datain

Details

For the optimzation of the trees, we employ a method we call Sumping (Subsampling umbrella of model parameters), a variant of Bumping (Bootstrap umbrella of model parameters) (Tibshirani & Knight, 1999). We use subsampling instead of bootstrapping. The aim of the optimization is to identify conditional inference trees with maximum predictive power on the full sample under interpretability restrictions.

Reference
Tibshirani, R., Knight, K. 1999. Model Search and Inference By Bootstrap "bumping". Journal of Computational and Graphical Statistics, Vol. 8, No. 4 (Dec., 1999), pp. 671-686

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.
The plot function will produce a series of more than one plot. If you use R, you might want to specify windows(record=TRUE) before plot(name) to save the whole series of plots. In R-Studio this functionality is provided automatically.

Examples

Run this code
data <- PrInDT::data_vowel
data <- na.omit(data)
ctestv <- 'vowel_maximum_pitch <= 320'
N <- 30 # no. of repetitions
pobs <- c(0.70,0.60) # percentages of observations
ppre <- c(0.90,0.70) # percentages of predictors
outreg <- PrInDTreg(data,"target",ctestv,N,pobs,ppre)
outreg
plot(outreg)

Run the code above in your browser using DataLab