Showing posts with label uncertainty. Show all posts
Showing posts with label uncertainty. Show all posts

Monday, October 20, 2014

Moar Accuracies

You've probably heard the saying, "It's better to be mostly accurate than precisely wrong." But what does that mean exactly? Aren't accuracy and precision basically the same thing?

Accuracy relates to the likelihood that outcomes fall within a prediction band or measurement tolerance. A prediction/measurement that comprehends, say, 90% of actual outcomes is more accurate than a prediction/measurement that comprehends only 30%. For example, let's say you repeatedly estimate the number of marbles in several Mason jars mostly full of marbles. An estimate of "more than 75 marbles and less than 300 marbles" is probably going to be correct more often than "more than 100 marbles but less than 120 marbles." You might say that's cheating. After all, you can always make your ranges wide enough to comprehend any range of possibilities, and that is true. But the goal of accuracy is just to be more frequently right than not (within reasonable ranges), and wider ranges accomplish that goal. As I'll show you in just a bit, accuracy is very powerful by itself.

Precision relates to the width of the prediction/measurement band relative to the mean of the prediction/measurement. A precision band that varies around a mean by +/- 50% is less precise than one that varies by +/- 10%. When people think about a precise prediction/measurement, they usually think about one that is both accurate and precise. A target pattern usually helps make a distinction between the two concepts.
The canonical target pattern explanation of accuracy and precision.

The problem is that people jump past accuracy before that attempt to be precise, thinking that the two are synonymous. Unfortunately, unrecognized biases can make precise predictions extremely inaccurate, hence the proverbial saying. Jumping ahead of the all too important step of calibrating accuracy is where the "precisely wrong" comes in.

Good accuracy trucks many more miles in most cases than precision, especially when high quality, formal data is sparse. This is because the marginal cost of improving accuracy is usually much less than the marginal costs of improved precision, but the payoff for improved accuracy is usually much greater. To understand this point, take a look again at the target diagram above. The Accurate/Not Precise score is higher than the Not Accurate/Precise score. In practice, a lot of effort is required to create a measurement situation that effectively controls for the sources of noise and contingent factors that swamp efforts to be reasonably more precise. Higher precision usually comes at the cost of tighter control, heightened attention on fine detail, or advanced competence. There are some finer nuances even here in the technical usages of the terms, but these descriptions work well enough for now.

Be careful, though - being more accurate is not just a matter of going with your gut instinct and letting that be good enough. Our gut instinct is frequently the source of the biases that make our predictions look as if we were squiffy when we made them. We usually achieve improved accuracy through the deliberative process of accounting for the causes and sources of the variation (or range of outcome) we might observe in the events we're trying to measure or predict. The ability to do this reflects the depth of expert knowledge we possess about the system we're addressing, the degree of nuances we can bring to bear to explain the causes of variation, and a recognition of the sources of bias that may affect our predictions. In fact, achieving good accuracy usually begins by assessing that we may be biased at all (and we usually are) and why.

Once we've achieved reasonable accuracy about some measurement of concern, it might then make sense to improve our precision of the measurement if the payoff is worth the cost of intensified attention and control. In other words, we only need to improve our precision when it really matters.
[Image from FreeDigitalPhotos.net by Salvatore Vuono.]

Tuesday, February 25, 2014

How Do You Know That? Funny You Should Ask.

During a recent market development planning exercise, my client recognized that his colleagues were making some rather dubious assumptions regarding the customers they were trying to address (i.e., acceptable price, adoption rate, lifecycle, market size, etc.), the costs of development, and costs of support. Although he frequently asked “How do you know that?”, he seemed to face irritation and mild belligerence in reaction from those he asked to justify their assumptions. So, together we devised a simple little routine to force the recognition that assumed facts might be shakier than previously thought.

After bringing the development team members together, we went around the room and asked for a list of statements that each believed to be true that must be true for the program to succeed. We wrote each down as a succinct, declarative statement. Then, after everyone had the opportunity to reflect on the statements, we converted each to a question simply by converting the periods to question marks.

Before Western explorers proved that the Earth is round, ships used to sail right off the assumed edges.

We then asked the team to supply a statement that answered each question in support of the original statement. Once this was completed, we then appended the dreaded question mark to each of these responses. We repeated this process until no declarative answers could be supplied in response to the questions. The cognitive dissonance among the team members became palpable as they all had to start facing the uncomfortable situation that what they once advocated as fact was largely unsupportable. Many open questions remained. More uncertainty reigned than was previously recognized. The remaining open questions then became the basis for uncertainties in our subsequent modeling efforts in which we examined value tradeoffs in decisions as a function of the quality of information we possessed. You probably won’t be surprised to learn that the team faced even more surprises as the implications of their tenuous assumptions came to light.

I am interested to know how frequently you find yourself participating in planning exercises at work in which key decisions are made on the basis of largely unsupported or untested assumptions. My belief is that such events happen much more often than we care to admit.

I would also be interested to know if the previously described routine works with your colleagues to force awareness of just how tenuous many preconceived notions really are. I outline the steps below for clarity.
  1. Write down everything you believe to be true about the issue or subject at hand. 
  2. Each statement should be a single declarative statement. 
  3. Read each out loud, forcing ownership of the statement.
  4. Convert each statement to a question by changing the period to a question mark.
  5. Again, read each out loud as a question, opening the door to the tentative nature of the original statement.
  6. Supply a statement that you believe to be true that answers each question.
  7. Repeat the steps above until you reach a point with each line of statements-questions where you can no longer supply answers.
You might find that using a mind mapping tool such as MindNode or XMind are useful for documenting and displaying the assumptions and branching question/responses. The visual display may serve to help your team see connections among assumptions that were not previously recognized.

Let me know if you try this and how well it works.

Tuesday, July 23, 2013

Business Case Analysis with R

The following is the first chapter excerpt from my newly published book.

Business Case Analysis with R

A Simulation Tutorial to Support Complex Business Decisions


1.2 Why use R for Business Case Analysis?
Even if you are new to R, you most likely have noticed that R is used almost exclusively for statistical analysis, as it's described at The R Project for Statistical Computing. Most people who use R do not frequently employ it for the type of inquiry which business case analysts use spreadsheets to select projects to implement, make capital allocation decisions, or justify strategic pursuits. The statistical analysis from R might inform those decisions, but most business case analysts don't employ R for those types of activities.

Obviously, as the title of this document suggests, I am recommending a different approach from the status quo. I'm not just suggesting that R might be a useful replacement for spreadsheets; rather, I'm suggesting that better alternatives to spreadsheets be found for doing business case analysis. I think R is a great candidate. Before I explain why, let me explain why I don't like spreadsheets.

Think about how a spreadsheet communicates information. It essentially uses three layers of presentation:
  1. Tabulation
  2. Formulation
  3. Logic
When we open a spreadsheet, usually the first thing we see are tables and tables of numbers. The tables may have explanatory column and row headers. The cells may have descriptive comments inserted to provide some deeper explanation. Failure to provide these explanatory clues represents more a failing of the spreadsheet developer's communication abilities than a failing of the spreadsheet environment, but even with the best of explanations, the emergent pattern implied by the values in the cells can be difficult to discern. Fortunately, spreadsheet developers can supply graphs of the results, but even those can be misleading chart junk.

To understand how the numbers arise, we might ask about the formulas. By clicking in a cell we can see the formulas used, but unfortunately the situation here is even worse than the prior level of presentation of tables of featureless numbers. Here, we don't see formulas written in a form that reveals underlying meaning; rather, we see formulas constructed by pointing to other cell locations on the sheet. Spreadsheet formulation is inherently tied to the structural presentation of the spreadsheet. This is like saying the meaning of our lives should be dependent on the placement of furniture in our houses.

While the goal of good analysis should not be more complex models, a deeper inquiry into a subject usually does create a need for some level of complexity that exceeds the simplistic. But as a spreadsheet grows in complexity, it becomes increasingly difficult to extend the size of tables (both by length of indices that structure them and the number of indicies used to configure the dimensionality) as a direct function of its current configuration. Furthermore, if we need to add new tables, choosing where to place them and how to configure them also depends almost entirely on the placement and configuration of previously constructed tables. So, as the complexity of a spreadsheet does increase, it naturally leads to less flexibility in the way the model can be represented. It becomes crystalized by the development of its own real estate.

The cell referencing formulation method also increases the likelihood of error propagation because formulas are generally written in a quasi-fractal manner that requires the formula to be written across every element in at least one index of a table's organizing structure. Usually, the first instance of a required formula is written within one element in the table; then, it is copied to all the appropriate adjacent cells. If the first formula is incorrect, all the copies will be, too. If the formula is sufficiently long and complex, reading it to properly debug it becomes very difficult. Really, the formula doesn't have to be that complicated or the model that complex for this kind of failure to occur, as the recent London Whale VaR model and Reinhart-Rogoff Study On Debt debacles demonstrated.[1]

All of this builds to the most important failure of spreadsheets -- the failure to clearly communicate the underlying meaning and logic of the analytic model. The first layer visually presents the numbers, but the patterns in them are difficult to discern unless good graphical representations are employed. The second layer, which is only visible unless requested, uses an arcane formulation language that seems inherently irrational compared to the goal of good analysis. The final layer--the logic, the meaning, the essence of the model--is left almost entirely to the inference capability of any user, other than the developer, who happens to need to use the model. The most important layer is the most ambiguous, the least obvious. I think the order should be the exact opposite.

When I bring up these complaints, the first response I usually get is: "ROB! Can't we just eat our dinner without you complaining about spreadsheets again?" But when the population of my dinner company tends to look more like fellow analysts, I get, "So what? Spreadsheets are cheap and ubiquitous. Everyone has one, and just about anyone can figure out how to put numbers in them. I can give my analysis to anyone, and anyone can open it up and read it."

Then I'm logically--no, morally--compelled to point out that carbon monoxide is cheap and ubiquitous, that everyone has secrets, that just about everyone knows how to contribute to the sewage system, that just about everyone can read your diary and add something to it. Free, ubiquitous, and easy to use are all great characteristics of some things in their proper context, but they aren't characteristics that are necessarily universally beneficial.

More seriously, though, I know that what most people have in mind with the common response I receive is the low cost of entry to the use of spreadsheets and the relative ease of use for creating reports (which I think spreadsheets are excellent for, by the way). Considering the shortcomings and failure of spreadsheets based on the persistent errors I've seen in client spreadsheets and the humiliating ones I've created, I think the price of cheap is too high. The answer to the first part of their objection--spreadsheets are cheap--is that R is free. Freer, in fact, than spreadsheets. In some sense, it's even easier to use since the formulation layer can be written directly in a simple text file without intermediate development environments. Of course, R is not ubiquitous, but it is freely available on the internet.

Unlike spreadsheets, R is programming language with the built in capacity to operate over arrays as if they were whole objects, a feature that demolishes any justification for cell-referencing syntax of spreadsheets. Consider the following example.

Suppose we want to model a simple parabola over the interval (-10, 10). In R, we might start by defining an index we call x.axis as an integer series.

x.axis <– -10:10

which looks like this,

> [1] -10  -9  -8  -7  -6  -5  -4  -3  -2  -1 0  1  2  3  4  5  6  7  8  9  10

when we call x.axis.

To define a simple parabola, we then write a formula that we might define as

parabola <– x.axis^2

which produces, as you might now expect, a series that looks like this:

>[1] 100  81  64  49  36  25  16  9  4  1  0  1  4  9  16  25  36  49  64  81 100.

Producing this result in R required exactly two formulas. A typical spreadsheet that replicates this same example requires manually typing in 21 numbers and then 21 formulas, each pointing to the particular value in the series we represented with x.axis. The spreadsheet version produces 42 opportunities for error. Even if we use a formula to create the spreadsheet analog of the x.axis values, the number of opportunities for failure remains the same.

Extending the range of parabola requires little more than changing the parameters in the x.axis definition. No additional formulas need be written, which is not the case if we needed to extend the same calculation in our spreadsheet. There, more formulas need to be written, and the number of potential opportunities for error continues to increase.

The number of formula errors that are possible in R is directly related to the total number of formula parameters required to correctly write each formula. In a spreadsheet, the number of formula errors is a function of both the number of formula parameters and the number of cell locations needed to represent the full response range of results. Can we make errors in R-based analysis? Of course, but the potential for those errors is exponentially smaller.

As we've already seen, too, R operates according to a linear flow that guides the development of logic. Also, variables can be named in a way that makes sense to the context of the problem[2] so that the program formulation and business logic are more closely merged, reducing the burden of inference about the meaning of formulas for auditors and other users. In Chapter 2, I'll present a style guide that will help you maintain clarity in the definition of variables, function, and files.

However, while R answers the concerns of direct cost and the propagation of formula errors, its procedural language structure presents a higher barrier to improper use because it requires a more rational, structured logic than is required by spreadsheets, requiring a rigor that people usually learn from programming and software design. The best aspect of R is that it communicates the formulation and logic layer of an analysis in a more straightforward manner as the procedural instructions for performing calculations. It preserves the flow of thought that is necessary to move from starting assumptions to conclusions. The numerical layer is presented only when requested, but logic and formulation are more visibly available. As we move forward through this tutorial, I'll explain more how these features present themselves for effective business case analysis.

1.3 What You Will Learn
This document is a tutorial for learning how to use the statistical programming language R to develop a business case simulation and analysis. I assume you possess at least the skill level of a novice R user.

The tutorial will consider the case in which a chemical manufacturing company considers constructing a new chemical reactor and production facility to bring a new compound to market. There are several uncertainties and risks involved, including the possibility that a competitor brings a similar product online. The company must determine the value of making the decision to move forward and where they might prioritize their attention to make a more informed and robust decision.

The purpose of the book is not to teach you R in a broad manner. There are plenty of resources that do that well now. Rather, it will attempt to show you how to

  • Set up a business case abstraction for clear communication of the analysis
  • Model the inherent uncertainties and resultant risks in the problem with Monte Carlo simulation
  • Communicate the results graphically
  • Draw appropriate insights from the results
So, while you will not necessarily become a power user of R, you will gain some insights into how to use this powerful language to escape the foolish consistency of spreadsheet dependency. There is a better way.

1.4 What You Will Need
To follow this tutorial, you will need to download and install the latest version of R for your particular OS. R can be obtained here. Since I wrote this tutorial with the near beginner in mind, you will only need the base install of R and no additional packages.


Notes
1: You will find other examples of spreadsheet errors at Raymond Panko's website. Panko researches the cause and prevalence of spreadsheet errors.

2: Spreadsheets allow the use of named references, but the naming convention can become unwieldy if sections in an array need different names.


Read more here: Or, if you prefer Amazon or Scribd.

Wednesday, March 06, 2013

Never Tell Me The Odds?

In a previous post, I discussed the meaning of expected value (EV) and how it's useful for comparing the values of choices we could make when the outcomes we face with each choice vary across a range of probabilities. The discussion closed by comparing the choice to play two different games, each with different payoffs and likelihoods. Game 1 returns an EV of $5, even though it could never actually produce that outcome; and Game 2 returns an EV of $4, also being incapable of producing that outcome.

But let's say that you hate it when C-3PO tells you the odds, so you commit to Game 2 because you like the upside potential of $15, and you think the potential loss of $5 is tolerable. After all, Han Solo always beat the odds, right? Well, before you so commit, let me encourage you to look into my crystal ball to show you what the future holds…not just in one future, but many.

Figure 1: Han Solo shakes his finger.
C-3PO: “Sir, the possibility of successfully navigating an asteroid field is approximately 3,720 to 1.”
Han Solo: “Never tell me the odds.”
I set up an Analytica model with the following characteristics. A sequence index (Play Sequence) steps from 1 to 1,000. Over this index I will toss two "coins," one with Probability of Win of 50% (Game 1), and the other (Game 2) with Probability of Win of 45% according to the way I set up the game in my last post. Each Game tosses the coin independently across the Play Sequence, recording the outcome on each step. A Game Reward ($10 for Game 1; $15 for Game 2) is allocated to a win, and a Game Penalty ($0 for Game 1; -$5 for Game 2) is allocated to a loss. Then, I cumulate the net Game Earnings across the Play Sequence to show on what value the cumulative earnings might converge for many repeated games choices. Not only do I play the games over 1000 sequence steps, I also play the sequences across 1000 universes of parallel iterations. From this point forward, I will refer to an "iteration" as the pattern that occurs in one of these parallel universes across the 1000 games it plays in sequence.
Figure 2: Analytica Influence Diagram. After each game step, wins are assigned a reward; losses, a penalty. Net returns are accrued.
What do we observe? In one iteration, we see you start off accruing net earnings in excess of the higher valued Game 1 across the first 400 or so games; however, your luck turns. You end up regretting not taking Game 1.
Figure 3: A streak of early wins can deceive your long term anticipations.
In another iteration, you marginally regret not taking Game 1. You can easily imagine that the outcome could be slightly reversed from this, finding yourself happy that Game 2 just beat out Game 1. Would that outcome prove anything about your skill as a gambler?
Figure 4: You might come close to beating the odds. It appears conceivable that you can. Maybe your luck will turn in the next game you play.
But of course, your luck might turn out much worse. In another iteration, you really regret your bravado.
Figure 5: Yikes!
"Of course," you say, "because the probabilities tell me that I might expect some unfortunate outcomes as well as some beneficial ones. But what overlap might there be over all the iterations at play? Is there some universe in which the odds ever really are in my favor?"

Here's what we see. For Game 1, the accrued earnings range from ~$4,500 to ~$5,500 by the 1000th step.
Figure 6: the accrued earnings range from ~$4,500 to ~$5,500 by the 1000th step for Game 1.
For Game 2, the accrued earnings range from ~$3,000 to ~$5,100. Clearly, some overlap potential exists out there.
Figure 7: the accrued earnings range from ~$3,000 to ~$5,100 for Game 2.
In fact, in the early stages of the game sequences, the potential for overlap appears to be significant, and there seems to be a set of futures where the overlap persists. You might just make that annoying protocol droid wish he had silenced his electronic voice emulator.

But take a second look. That second-from-the-top band for Game 2 converges on the second-from-the-bottom band in Game 1. These are the upper and lower 5th percentile bands of the outcome, respectively.
Figure 8: The final distributions of the two games shows that there are some universes in which your luck holds up...a very small amount of up.
When we count how likely it is that Game 2 ends in winning conditions at various intervals points along the way, the perceived benefit in the higher potential reward of Game 2 decays rapidly. Before you even start, the chance that you could be in a better position by step 1000 for taking Game 2 is around half a percent.
Figure 9: The long-term perspective of maintaining a winning position in decays rapidly for Game 2.
In the model, note that the average earnings by step 1,000 for Game 1 is $5,000 (i.e., 1000*EV1) and that the earnings for Game 2 is $4,000 (i.e., 1000*EV2). It's as if the imputed EV of each game inexorably accumulated over time…a very long time and over many universes.

So it is in the fantasy of Hollywood that the mere mention of long odds ensures the protagonist's success. Unfortunately, life doesn't always conform to that fantasy. Over a long time and many repeated occasions to play risky games, especially those that afford little opportunity to adjust our position or mitigate our exposure, EV tells us that our potential for regret increases for having chosen the lesser valued of the two games. Depending on the relative size of the EVs between the two choices, that potential for regret can occur rapidly as the inherent outcome signal implied by the EV begins to overwhelm the potential short-term lucky outcomes in the random noise of the game.

So how can you know when you will be lucky? You can't. The odds based on short-term observations of good luck will not long be in your favor. Your fate will likely regress to the mean.

(This post was also simultaneously published at the Lumina Blog.)

Thursday, February 07, 2013

A Brief Explanation of Expected Value

When helping people analyze the risks they face in complex decisions, I frequently receive requests for an explanation of expected value, as expected value is a measure commonly used to compare the value of alternate risky options. I’ve found that by now most people understand the concept of net present value (NPV) rather well, but they still struggle with the concept of expected value (EV)*. Interestingly enough, and fortunately so, the two concepts share some relationship to each other that makes an explanation a little simpler.

NPV is the means by which we consistently compare cash flows shaped differently in time, assuming that money has a greater meaning to us when we get it or spend it sooner rather than later. For example, NPV would help us understand the relative value of a net cash stream that experienced a small draw down in early periods but paid it back in five years versus a net cash stream that makes a larger draw down in early periods but pays it back in three years.

EV is similar. By it we consistently compare future outcome values that face different probabilities of occurring.

When we do NPV calculations, we don’t anticipate that the final value in our bank account necessarily will equal the NPV calculated. The calculation simply provides a way to make a rational comparison among alternate time-distributed cash streams.

Likewise, when we do EV calculations, we don’t anticipate that the realized value necessarily will equal the EV. In fact, in some cases it would be impossible for that outcome to be the case. EV just simply provides a way to make a rational comparison among alternate probability-distributed outcomes.

Here’s a simple example. Suppose I offer you two gambles to play in order to win some money. (Not really, of course, because the State of Georgia reserves the right to engage in games of chance but prohibits me from doing so.)

In the first game, there are even odds (probability=50%) that you will win either $10 on the outcome of a head or $0 on a tail.

In the second game, which is a little more complicated, I use a biased coin for which the odds are slightly less than even, say, 9:11 (probability=45%), of your winning. If you win, you gain $15; lose, you pay me $5. Which is the better game to play? Believe it or not, the answer depends on how you frame the problem, most notably from your perspective of risk tolerance and how many games you get to play. If you can’t afford to pay $5 if you lose the second game on the first toss, you’re better off to go with the first game because you will lose nothing at least and gain $10 at best. However, if you can afford the possible loss of $5 and you can play the game repeatedly over numerous times, expected value tells us how to compare the two options.

We calculate EV in the following way: EV = prob(H)*(V|H) + prob(T)*(V|T).

For the first game, EV1 = 0.5*($10) + 0.5*(0) = $5.

For the second game, EV2 = 0.45*($15) – 0.55*($5) = $4.

So, since you prefer $5 over $4 (you do, don’t you?), you should play the first game, even though the potential maximum award is alluringly $5 more in game two than one.

But here's the point about the outcomes. At no time in the course of playing either game will you have $5 or $4 in your pocket. Those numbers are simply theoretical values that we use to make a probability-adjusted consistent comparison between two risky options.

In a follow up post, I will describe what your potential winnings could look like if you choose to play either game over many iterations across many parallel universes.

*To be honest, I think part of the persistent problem in understanding is contributed by the term "expected" itself. Colloquially, when people use and hear this term, they think "anticipated." In discussions about risk and uncertainty, the technical meaning really refers to a probability weighted average or mean value. Unfortunately, I don't expect that you should wait for us technical types to accommodate common usage. [back]