0
votes

I am an intern and my boss wants me to make a decision tree that results in the likelihood of someone being / becoming diabetic. I am extremely new to R and currently the only one that I work with that is using R... I need the decision tree to be based on the following criteria:

if(A1CValue >= 8)
{print('highly likely')}
else if(BSValue >= 140)
{print("highly likely")}
else if(DBPValue >= 80)
{print("highly likely")}
else if(SBPValue >= 140)
{print("highly likely")}
else 
{print("less likely")
}

Can anyone assist me in the coding to put this into a decision tree? Thanks in advance, Laura

1
How do you know that these creterias are correct? Someone already made a decision tree and received thiese results? Also, what do you mean by "your boss wants you to make a decision tree" if you already have the rules? You mean that you want the plot? You can take a look in partykit package too cran.r-project.org/web/packages/partykit/partykit.pdf - David Arenburg
Maybe the function rpart() in base R, and the packages plot.rpart/rpart.plot also warrant a mention here? - user2357031
Learn a bit of R first. Learn about data frames and functions. Then you can write a function that operates on a data frame and returns the result of the decision tree. The decision tree function would look a lot like your sample code, except setting the result rather than printing something out. - Spacedman
Well, the criteria has been determined from medical journals of the limits for each test result. - decisionsciencestudent

1 Answers

3
votes

If you already have splitting criteria then there is no point in using R to create a tree... just draw the tree in whatever graphic software you like!

The best thing, however, would be to let R do the job.

You may want to look at packages such as tree or randomForest.

I may also suggest these videos from the StatLearning course (be sure to check out their free book An Introduction to Statistical Learning too!)

8.1 Tree-based methods
8.2 More details on Trees
8.3 Classification trees
8.4 Bagging and Random forests
8.5 Boosting
8.R Tree-Based Methods in R part 1 and part 2