Relationship between a pair of stocks

Linear Regression

The easiest relationship to examine between a pair of stocks is linearity. You can try and fit a linear model through their daily log returns first and then decide further course of action.

Here’s a scatter-plot that shows how Bank of India and Canara Bank could be related to each other.

canbk-bankindia

Results of linear regression:

Residuals:
      Min        1Q    Median        3Q       Max 
-0.055050 -0.009995  0.000331  0.009440  0.063258 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept) -0.0002843  0.0006817  -0.417    0.677    
BANKINDIA    0.7451950  0.0232860  32.002   <2e-16 ***
---
Residual standard error: 0.01638 on 575 degrees of freedom
Multiple R-squared:  0.6404,    Adjusted R-squared:  0.6398 
F-statistic:  1024 on 1 and 575 DF,  p-value: < 2.2e-16

After fitting a regression model it is important to determine whether all the necessary model assumptions are valid before performing inference. If there are any violations, subsequent inferential procedures may be invalid resulting in faulty conclusions. Therefore, it is crucial to perform appropriate model diagnostics.

Residuals vs. Fitted

Residuals are estimates of experimental error obtained by subtracting the observed responses from the predicted responses. The predicted response is calculated from the model after all the unknown model parameters have been estimated from the data. Ideally, we should not see any pattern here.

residuals vs fitted

scaled residuals

Q-Q Plot of Residuals

The QQ Plot shows fat tails.

qq plot of residuals

Residuals vs. Leverage

The leverage of an observation measures its ability to move the regression model all by itself by simply moving in the y-direction. The leverage measures the amount by which the predicted value would change if the observation was shifted one unit in the y-direction. The leverage always takes values between 0 and 1. A point with zero leverage has no effect on the regression model. If a point has leverage equal to 1 the line must follow the point perfectly.

Labeled points on this plot represent cases we may want to investigate as possibly having undue influence on the regression relationship.

 residuals vs leverage

Conclusion

A linear model on daily log returns may not be the best way to understand the relationship between the two stocks. We can either change the model (linear) or change the attribute (daily log returns) that we are using.

To be continued…

Source: Model Diagnostics for Regression

Nifty Statistical Study

Returns vs. Log Returns

We had discussed how the most important assumption in finance is that returns are normally distributed. Also, the benefit of using returns, versus prices, is normalization. All your variables are now on the same scale and can be compared easily. But if you pick up any book on financial statistical modelling, you’ll run into log returns more often.

nifty-daily-returns

nifty-daily-log-returns

As you can see from the charts above, visually, they don’t make a difference. However, taking the log of returns makes the math easier:

  1. If we assume that prices are distributed log normally, then log(1+ri), where ri is the ith period return, is normally distributed. And we know how to work with normal distributions.
  2. When returns are very small, log(1+ri) ≈ r
  3. Calculating compounding return goes from series multiplication (∏) to series summation (∑).

nifty-histogram

nifty-log-histogram

Quantiles

The easiest way to summarize a frequency distribution is through quantiles. Quantiles are values which divide the distribution such that there is a given proportion of observations below the quantile. For example, the median is a quantile such that half the points are less than or equal to it and half are greater than or equal to it.

Raw-returns (%):

1% 5% 25% 50% 75% 95% 99%
-4.1986 -2.4994 -0.6992 0.0967 0.8585 2.4387 4.4465

Log-returns:

1% 5% 25% 50% 75% 95% 99%
-0.04289 -0.0253 -0.0070 0.0009 0.0085 0.0240 0.0435

Q-Q Plot

Once we know the qunatiles of our log returns, we can compare it to that of a normal distribution. When you plot the quantiles of the sample (Nifty daily log returns) to the quantiles of a theoretical normal distribution, you get a visual feel for the outliers – the fat tails.

nifty-log-returns-normal-qq-plot

This plot shows that both tails are heavier than the tails of the normal distribution. So, although using log returns and assuming that prices are distributed log normally makes the math easier, we should always be aware that it is a sleight of hand.

To be continued…

Sources:

Markets 24.04.2014

Indian markets are closed due to elections in Mumbai. Here’s a roundup of world markets and the latest flash PMI numbers.

Your world at 9am

world equity markets 2014-04-24

Equities

Major
DAX(DEU) -0.58%
CAC(FRA) -0.74%
UKX(GBR) -0.11%
NKY(JPN) -0.44%
SPX(USA) -0.22%
MINTs
JCI(IDN) +0.18%
INMEX(MEX) -0.62%
NGSEINDX(NGA) -0.54%
XU030(TUR) -0.51%
BRICS
IBOV(BRA) -0.78%
SHCOMP(CHN) -0.11%
NIFTY(IND) +0.37%
INDEXCF(RUS) -0.49%
TOP40(ZAF) -0.14%

Commodities

Energy
Brent Crude Oil +0.17%
Ethanol +0.00%
Heating Oil +0.09%
Natural Gas +1.01%
RBOB Gasoline +0.16%
WTI Crude Oil +0.23%
Metals
Copper +0.26%
Gold 100oz +0.16%
Palladium -0.03%
Platinum +0.13%
Silver 5000oz +0.00%

Currencies

USDEUR:+0.00% USDJPY:-0.10%

MINTs
USDIDR(IDN) -0.04%
USDMXN(MEX) +0.06%
USDNGN(NGA) +0.24%
USDTRY(TUR) -0.00%
BRICS
USDBRL(BRA) -0.71%
USDCNY(CHN) +0.06%
USDINR(IND) +0.52%
USDRUB(RUS) -0.04%
USDZAR(ZAF) -0.06%
Agricultural
Cattle -0.02%
Cocoa +0.48%
Coffee (Arabica) -0.33%
Coffee (Robusta) +0.37%
Corn -0.30%
Cotton +0.10%
Feeder Cattle +0.10%
Lean Hogs -0.30%
Lumber -0.12%
Orange Juice +0.97%
Soybean Meal +0.08%
Soybeans -0.09%
Sugar #11 +2.06%
Wheat -0.59%
White Sugar +1.44%

PMI Roundup

China

Still below 50, but green shoots.

China PMI April 2014

US

Production rises at fastest pace for over three years.

US PMI April 2014

Eurozone

Business activity expansion nears three-year peak.

Eurozone PMI April 2014

Germany

Flash Germany Composite Output Index at 2 month high.

Germany PMI April 2014

France

Flash France Composite Output Index falls to 2-month low.

France PMI April 2014

Source: Markit

Musings on stock-market forecasts

Traffic jams

Say there’s a traffic jam on a busy road. When new vehicles try to enter the same route, the drivers hear on the radio that there’s a jam ahead and adapt by finding another route. Suppose there is only one alternate route. What happens now? The alternate route forms a second jam!

Later entrants have to choose between the two jams. Predicting the actions of this new group is very hard to do. Maybe the second jam is worse than the first. By the time we hit this third layer of participants, predicting the behavior of the system has become extremely difficult, if not impossible.

Complex vs. Complex Adaptive

Weather is a complex system. However, if, on Thursday, the forecast is for rain on Sunday, is the rain any less likely to occur? No. The act of predicting has not influenced the outcome. Although near-term weather is extremely complex, with many interacting parts leading to higher order outcomes, it does have an element of predictability.

The stock-market is a complex adaptive system. Traders and investors in the market are interacting with one another constantly and adapting their behavior to what they know about others’ behavior. The key element of a complex adaptive system is the social element.

For example, Meredith Whitney predicted the crash of Citibank in late 2007.

citi chart

She went on to setup her own advisory firm, Meredith Whitney Advisory Group, and made a similar call on American municipal bonds in late 2010 on national television. Retail investors sold in panic. But for the the most parts, nothing happened.

MUB chart

Reflexivity

Reflexivity refers to circular relationships between cause and effect. A reflexive relationship is bidirectional with both the cause and the effect affecting one another in a situation that does not render both functions causes and effects. It flies in the face of equilibrium theory, which stipulates that markets move towards equilibrium and that non-equilibrium fluctuations are merely random noise that will soon be corrected.

Reflexivity asserts that prices do in fact influence the fundamentals and that these newly-influenced set of fundamentals then proceed to change expectations, thus influencing prices; the process continues in a self-reinforcing pattern.

Takeaway

Behavioral dynamics is key to understanding complex adaptive systems. One should have a mental model that incorporates higher-order thinking when it comes to navigating the markets.

The big question is, how different is listening to stock-market predictions from listening to an astrologer, reading horoscopes or believing in vastu?

To quote German theologian and martyr Dietrich Bonhoeffer:

“…how wrong it is to use God as a stop-gap for the incompleteness of our knowledge. If in fact the frontiers of knowledge are being pushed further and further back (and that is bound to be the case), then God is being pushed back with them, and is therefore continually in retreat. We are to find God in what we know, not in what we don’t know.”
vastu
Sources
Related articles

Opening Bell 23.04.2014

Your world at 9am

world equity markets 2014-04-23

Equities

Major
DAX(DEU) +2.02%
CAC(FRA) +1.18%
UKX(GBR) +0.85%
NKY(JPN) +0.57%
SPX(USA) +0.41%
MINTs
JCI(IDN) -0.06%
INMEX(MEX) -0.64%
NGSEINDX(NGA) +0.21%
XU030(TUR) -0.51%
BRICS
IBOV(BRA) -0.26%
SHCOMP(CHN) -0.45%
NIFTY(IND) -0.03%
INDEXCF(RUS) -0.70%
TOP40(ZAF) +0.61%

Commodities

Energy
Brent Crude Oil +0.00%
Ethanol +0.00%
Heating Oil +0.09%
Natural Gas +0.06%
RBOB Gasoline -0.02%
WTI Crude Oil -0.19%
Metals
Copper +0.00%
Gold 100oz +0.00%
Palladium +0.37%
Platinum +0.36%
Silver 5000oz +0.00%

Currencies

USDEUR:-0.07% USDJPY:-0.08%

MINTs
USDIDR(IDN) +0.99%
USDMXN(MEX) +0.06%
USDNGN(NGA) +0.15%
USDTRY(TUR) +0.00%
BRICS
USDBRL(BRA) +0.04%
USDCNY(CHN) +0.08%
USDINR(IND) +0.29%
USDRUB(RUS) -0.01%
USDZAR(ZAF) -0.01%
Agricultural
Cattle -0.16%
Cocoa -100.00%
Coffee (Arabica) +7.32%
Coffee (Robusta) -100.00%
Corn -0.20%
Cotton +0.04%
Feeder Cattle +0.14%
Lean Hogs -0.43%
Lumber +0.39%
Orange Juice +0.82%
Soybean Meal -0.06%
Soybeans -0.30%
Sugar #11 +0.95%
Wheat -0.30%
White Sugar +1.94%

Must reads

Insider trading in India: In the few cases where SEBI has been able to get enough evidence to prosecute, the court cases have sometimes taken more than a decade to make their way through India’s overburdened court system. And Even if insider traders are caught and found guilty after long trials, the punishments have often been too light to offset the potential profits. (WSJ)

Modi says that willpower, decisive leadership needed for India to grow like Gujarat. (LiveMint). But What can Modi do? And just in case: What if: abki baar NO modi sarkar?

Palcohol, the alcohol that you can snort. Enough said. (Pando)

Markets are closed tomorrow due to elections in Mumbai. Futures and Options expirations have been brought forward today. Good luck!