PredPsych (version 0.1)

DTModel: Generic Decision Tree Function

Description

A simple function to create Decision Trees

Usage

DTModel(Data, classCol, selectedCols, tree, ...)

Arguments

Data

(dataframe) a data frame with regressors and response

classCol

(numeric) which column should be used as response col

selectedCols

(optional)(numeric) which columns should be treated as data(features + response) (defaults to all columns)

tree

which decision tree model to implement; One of the following values:

  • CART = Classification And Regression Tree;

  • CARTNAHF = Crossvalidated Half Model CART Tree removing missing values;

  • CARTHF = Crossvalidated Half Model CART Tree With missing values;

  • CF = Conditional inference framework Tree;

  • RF = Random Forest Tree;

...

(optional) additional arguments for the function

Value

model result for the input tree Results

Details

The function implements the Decision Tree models (DT models). DT models fall under the general "Tree based methods" involving generation of a recursive binary tree (Hastie et al., 2009). In terms of input, DT models can handle both continuous and categorical variables as well as missing data. From the input data, DT models build a set of logical "if ..then" rules that permit accurate prediction of the input cases.

Unlike regression methods like GLMs, Decision Trees are more flexible and can model nonlinear interactions.

Examples

Run this code
# generate a cart model for 10% of the data with cross-validation
model <- DTModel(Data = KinData[,c(1,2,12,22,32,42,52,62,72,82,92,102,112)],
classCol=1,tree='CARTHF')

Run the code above in your browser using DataLab