This is the second article in my getting started with analytics series. We're going to spend some time discussing the fundamental segments of analytics and an example of each. There are numerous frameworks to support types of analytics. As I was writing the article I reviewed 3 different books on analytics, making sure that my comments hold academic merit, and each has classified the segments of analytics in different ways.
The types of analytics land somewhere from 3 to 5 different types in my research. One of the more common breakdowns has 4 types; generally considered to be an evolution starting with descriptive and moving to diagnostic, predictive, prescriptive respectively.
Descriptive Analytics seeks to answer “what happened”. This type of analytics reviews data and uses a lot of traditional research approaches. Generally, Classical or Bayesian statistical methods are used to learn about the data set. An example would be the average amount of money in a bank account on a monthly basis. Grab standard deviation and you have some idea of how much money someone keeps in their account and how much spending is occurring. The example below is a quick block of R code to show you how to get descriptive statistics from the iris data in R.
Example in R(Descriptive Statistics):
pairs(iris[1:4], main = "Iris Data", pch = 21, bg = c("blue", "yellow", "brown")[unclass(iris$Species)])
Diagnostic analytics seeks to answer why did something happen. I like to think of this as seeking potential causation for a decision. Depending on the individual they may characterize this as descriptive, but for discussion purposes it’s broken out into its own category. An example of diagnostic analytics might be a review of web click patterns on a website and building a decision tree that lets you see how someone is moving though the site as well as what’s being presented to them. This tree allows you to analyze that activity that has occurred. The example below provides a short review of how a decision tree model and plot can be built.
Example in R(Decision Tree Visualization):
model.rpart = rpart(Species~., data=iris, method=class)
plot(model.rpart, margin=.08, branch=.5, compress=TRUE, uniform=FALSE, main="IRIS Dataset Classification Tree")
text(model.rpart, fancy=TRUE,minlength=1, splits = TRUE, use.n=TRUE, all=TRUE)
Predictive Analytics seeks to answer what will happen in the future. It’s been around for a while with regression and time series analysis but new techniques are evolving every day. This branch of analytics focused on predicting what you may buy or do; think Google and what they're doing. There are a number of areas of predictive analytics as far as predicting values versus predicting classes. An example may be a sales forecast for your business. The code example below extends on the decision tree model above to try to predict the type of species of a plant from the iris data set.
Example in R(Iris Decision Tree Prediction):
model.rpart = rpart(Species~., data=iris)
Predicted = cbind(iris, predict = predict(model.rpart, iris, type="class"))
Prescriptive analytics seeks to determine what should be done. A stock portfolio optimization model is an example of this branch of analytics. Not only do we want to predict what might happen, but we want the model to tell us how we should allocate our portfolio as well. The code provided below is a simplified version of a stock portfolio optimization problem in R.
Example in R(Stock Portfolio Optimization):
stocks = getReturns(c("MSFT", "JPM", "GM", "VZ", "WFC", "PSX"), start="2014-01-01",end="2014-12-31")
model1 = stockModel(stocks)
optPort = optimalPort(model1, shortSell = TRUE)
I wrote the code above to facilitate understanding and isn't something to copy/paste and try to run at your business. My hope is that the concepts were useful as I found it difficult in the beginning of my own journey to find anything with examples. This space continues to evolve and we'll explore some more specific analytically approaches in later articles. Good luck with your own analytics!
Originally posted to https://www.linkedin.com/post/edit/getting-started-analytics-types-mike-butler