Whoever wrote the book on statistics, probably avoided getting a proper education in literature. At least that’s my null hypothesis. The cryptic and awkward presentation of probabilities common amongst the Frequentists (no, not the Latin American Socialist faction you’re thinking of) is legend. They speak of the null hypothesis and having a 95% confidence level that you can accept it. Some aren’t happy with that obfuscation and insist that it’s not proper to accept a null hypothesis, but only to reject or fail to reject the null hypothesis. Hmm, well okay I guess. There is another way though. It’s called Bayesian inference. Give it a look. It’s probably the only way known to mankind that you can be a nerd and cool at the same time.
Not that the Bayesian approach is easy to understand at first glance. It’s not difficult, but it’s also easy to get it wrong. My approach to learning was to write a program in R, which I appropriately named the “quote” — bayes_a_nator. This is a simple program and it’s assumptions are ridiculously naive, but you don’t build a killer algo without getting some basic machinery running first.
The following function takes two stocks from Yahoo Finance and calculates how often they have positive returns. It starts with the first stock’s positive return probability, and then gets the second stock’s positive return probability given that the first stock returned positive. Then it solves the riddle to the question: What is the probability that first stock is up, given that second stock is up? The algorithm does not calculate this implicitly, so the probability has to be inferred.
This program has five parts, and instead of pontificating about it, I’ll just let the comments speak for themselves. Enjoy the ASCII art.