Bootstrap example

Bootstrap your way into robust inference. Wow, that was fun to write..

Introduction
Say you made a simple regression, now you have your  \widehat{\beta} . You wish to know if it is significantly different from (say) zero. In general, people look at the statistic or p.value reported by their software of choice, (heRe). Thing is, this p.value calculation relies on the distribution of your dependent variable. Your software assumes normal distribution if not told differently, how so? for example, the (95%) confidence interval is  \widehat{\beta} \pm 1.96 \times sd( \widehat{\beta}) , the 1.96 comes from the normal distribution.
It is advisable not to do that, the beauty in bootstrapping* is that it is distribution untroubled, it’s valid for dependent which is Gaussian, Cauchy, or whatever. You can defend yourself against misspecification, and\or use the tool for inference when the underlying distribution is unknown.

More

Europe most dangerous cities

When I was searching for data about U.S prison population, for another post, I ran across eurostat, a nice source for data to play around with. I pooled some numbers, specifically homicides recorded by the police. A panel data for 36 cities over time, from 2000 to 2009. Lets see which are the cities that have problems in this area.

More

U.S. prison population

I recently finished reading: The author writes that 6.6% of U.S. American residents will find themselves at some point in their life incarcerated, about 20 million people. A big number on anyone’s scale. You can also find disturbing figures in Wikipedia: figure. Are these facts misleading? we need to account for population growth. The prison population should naturally rise even if the proportion of crime in the general population is constant, since the population itself is growing. Here I show that these facts are NOT misleading, and that the system is indeed not fulfilling its purpose.

More

Spurious Regression illustrated

Spurious Regression problem dates back to Yule (1926): “Why Do We Sometimes Get Nonsense Correlations between Time-series?”. Lets see what is the problem, and how can we fix it. I am using Morgan Stanley (MS) symbol for illustration, pre-crisis time span.  Take a look at the following figure, generated from the regression of MS on the S&P, actual prices of the stock, actual prices of the S&P, when we use actual prices we term it regression in levels, as in price levels, as oppose to log transformed or returns.

More

Live Rolling Correlation Plot

Open source is amazing! I cannot even start to imagine the amount of work invested in R, in firefox browser (Mozilla), or Rstudio IDE, all of which are used extensively around the globe, free. Not free as in: free sample till you decide to upgrade, or: sure it’s free, just watch this one minute commercial every time you need to use it,  but free, as in: we think it might make your life better, enjoy. Warms the heart, in direct opposite to the fabulous fabs out there, that instead of contributing to a better, safer society, set it back and get paid for it (see appendix). Character is also normally distributed I guess.

More

piecewise regression

A beta of a stock generally means its relation with the market, how many percent move we should expect from the stock when the market moves one percent.

Market, being a somewhat vague notion is approximated here, as usual, using the S&P 500. This aforementioned relation (henceforth, beta) is detrimental to many aspects of trading and risk management. It is already well established that volatility has different dynamics for rising markets and for declining market. Recently, I read few papers that suggest the same holds true for beta, specifically that the beta is not the same for rising markets and for declining markets. We anyway use regression for estimation of beta, so piecewise linear regression can fit right in for an investor/speculator who wishes to accommodate himself with this asymmetry.

More

Resistant Regression

It is a fact that on most days, not much is going on in the stock market. When we estimate the relation of a stock with the market, or the “beta” of a stock, we use all available daily returns. This might not be wise as some days are not really typical and contaminate our estimate. For example, Steve Jobs past away recently, AAPL moved quite a bit as a result. However, this is a distinct event that does not reflect on the relation with the market, but is company specific. Our aim is to exclude such observations, taking into consideration that we don’t want to lose too much information, not all large swings are irrelevant.

More

Price is right, part two – Trading strategy.

Having stock market in mind, in the previous post: “Price is right, part one.”,  I stated that we should not think in terms of “the price went up/down too much” but that “the current price level is wrong since…. and the market is not getting it because…”, bearing in mind that Mr. Market is not a weak player to say the least.

In this post I back this claim with the examination of a trading strategy that ignores economical arguments, thus is only based on relative price moves. Say you believe  my previous post is horseshit, wouldn’t it be nice to short the market if it’s “too high” and to long it when it “went down too much”? Fine!, let’s have a look at the performance of such a strategy.

More

Pairs Trading Issues

A few words for those of you who are not familiar with the “pairs trading” concept. First you should understand that the movement of every stock is dominated not by the companies performance but by the general market movement. This is the origin of many “factor models”, the factor that drives the every stock is the market factor, which is approximated by the S&P index in most cases.

More

OLS beta VS. Robust beta

In financial context,  \beta is suppose to reflect the relation between a stock and the general market. A broad based index such as the S&P 500 is often taken as proxy for the general market. The  \beta , without getting into too much detail, is estimated using the regression:

    \[stock_i = \beta_0+\beta_1market_i+e_i\]

A  \widehat{\beta_1} of say, 1.5 means that when the market goes up 1% the specific stock goes up 1.5%. (Ignoring all the biases at the moment!)

More

Flash Crash

In his book, “A demon of our design”: Richard Bookstaber talks about the concept of coupled systems. These are systems where, once launched, are impossible to shut down. One such process is a plain take off. Once started, the pilot has no way back, he cannot stop after getting off the ground, so the only way is up. Well, in financial markets, up is generally considered good,

More

Reducing Portfolio Fluctuation

THIS IS NOT INVESTMENT ADVICE.  ACTING BASED ON THIS POST MAY, AND IN ALL PROBABILITY WILL, CAUSE MONETARY LOSS.

Most of us are risk averse, so in our portfolio, we prefer to have stocks that will protect us to some extent from market deterioration. Simply put, when things go sour we want to own solid companies. This will reduce return fluctuation and will help our ulcer index against large downwards market swings. Large caps are such stocks. But which large caps should we chose? The squared returns are often taken as a proxy for the volatility so, keeping simplicity in mind, I use those.

More