Hot answers tagged

31

This one is quite easy: Think of a man walking his dog. He will go along and his dog will stroll along running back and forth. Man and dog are mathematically "cointegrated". As an investor you bet that the dog is coming back to his master or that the leash has only a certain length.


26

This isn't really an answer, but it's too long to add as a comment. I've always had a real problem with the correlation/covariance of price. To me, it means nothing. I realize that it gets used (abused) in many contexts, but I just don't get anything out of it (over time, price has to generally go up, go down, or go sideways, so aren't all prices ...


26

The standard story (also told by @vonjd) is of "The Drunk and Her Dog". This is based on "A Drunk and Her Dog: An Illustration of Cointegration and Error Correction" (1994). The story is itself based on the standard illustration for a random walk known as the "drunkard's walk". The Dickey-Fuller test is used to check for a unit root. It can be used as ...


20

Yes, the weights of the first eigenvector of a covariance matrix represent the market factor and also the largest source of systematic risk (variation of returns). Why PCA? Well, PCA simply identifies the eigenvector that maximally explains the variance of the system. It turns out that this is the "market factor" - i.e. the tendency of securities to rise ...


18

Variance ratio tests have been used numerous times to show that financial asset prices do not follow a random walk. You can for example look at -Lo and MacKinlay : Stock market prices do not follow a random walk : http://press.princeton.edu/books/lo/chapt2.pdf (US Stocks) -Hoque, Kim, Pyun: A comparison of variance ratio tests of random walk: A ...


17

My deal is HFT so what I care about is read/load data from file or DB quickly in memory perform very efficient data-munging operations (group,transform) visualize easily the data I think is is pretty clear that 3. goes to R, graphics and ggplot2 and others allow you to plot anything from scratch with little effort. About 1. and 2. I am amazed reading ...


14

Two time series $X_1$ and $X_2$ are cointegrated if a linear combination $aX_1+bX_2$ is stationary i.e. it has constant mean, standard deviation and autocorrelation function for some $a$ and $b$. In other words, the two series never stray very far from one another. Cointegration might provide a more robust measure of the linkage between two financial ...


13

This is interesting because I see another trend: Matlab is being replaced by R, but I guess this is another story. I use R for my academic (I am also teaching this stuff) as well as my consulting work (I am mainly working in the $\mathbb{P}$ area, with some excursions into $\mathbb{Q}$). I tried Python but it didn't work for me. I think the main reasons I ...


13

I've used both R and Python with Pandas in a professional quantitative financial work to do both large and small scale projects. I would strongly recommend Python with Pandas over R for most new projects in the field especially in time series analysis. While I don't dispute vonjd in that you will find more libraries in R with algorithms on the bleeding ...


12

Correlation is much more widely used concept and it has much more "informal" meanings. If we have only two random variables $X$ and $Y$ then correlation is simply a measure of linear dependence between the two variables: $$corr(X,Y)=\frac{cov(X,Y)}{\sqrt{var(X)var(Y)}}=\frac{EXY-EX\cdot EY}{\sqrt{var(X)var(Y)}}$$ If correlation is -1 or 1 then the two ...


12

From remote memory, The first question is Yes/No question. Is there any stationary, i.e. I(0), time series for different levels of combination r? This question is answered by your first table. For example, if [r=2]'s test stat is say 7 while the critical value of 99% confidence is 6.6 like your example, then I have over 99% confidence to say that all ...


12

There are a number of different tests that are generally used to compare samples to different distributions, such as Jarque-Bera, Anderson-Darling, and Kolmogorov–Smirnov (see this related question). In your case, with just the standard deviation and mean, there isn't a whole lot to say. You need to assume a distribution (e.g. normal). You would be able ...


12

It seems that your question refers to the microstructure noise defined in papers about intraday volatility estimates. Originally, it comes from the bid-ask bounce, i.e. the fact that even if the volatility is zero, you have buyers and sellers at this price and consequently you observe prices at Bid or Ask prices, and not at mid-price. Because of that, if ...


12

If the means are similar, then K-means will not do a great job. I would generate new features, perhaps based on higher moments of the distribution or some other properties (auto-correlation, summary of spectral density, etc.). Using this new set of features, If you see separation of two curves when you plot draws in feature space then k-means would be an ...


12

I don't know how to select ARMA lag length when doing ARMA-GARCH. Perhaps someone can edit it into this answer. For the univariate case you want rugarch package. If you're doing multivariate stuff you want rmgarch. The reason these are better than other packages is threefold; (i) Support for exogenous variables which I haven't seen in any other package, ...


11

Actually, co-skewness is represented by a rank 3 tensor, rather than a matrix. I'm going to reproduce the formulation from Bhandari and Das, Options on portfolios with higher-order moments, but I'll add and omit some details. The co-skewness tensor is $$ S_{ijk} = E \left[ r_i \times r_j \times r_k \right] = \frac{1}{T} \sum_{t=1}^T r_i(t) \times r_j(t) ...


11

Some cynical but functional definitions: It's what you can't model if you're not using tick by tick data It's what proper quant pricing theory doesn't know how to model yet It's information (order book behavior) that reflects momentary fluctuations in the supply/demand of a given contract, rather than its underlying value (eg an arbitrage free price) ...


11

Just to be painfully clear, it only seems to make sense to consider the logarithm of returns, i.e. $X=\log (1+\frac r{100})$ for a simple return of $r\%$ in an arbitrary period because this is what sums when returns are temporally aggregated. A basic property of cumulants is that cumulants of all orders are additive under convolution, for which a proof can ...


11

The clearest and most intuitive article I have seen so far is Kritzman et al., Regime Shifts: Implications for Dynamic Strategies in FAJ (May / June 2012) It not only shows how you can use HMM for financial modelling but it also goes through the actual estimation algorithm (Baum-Welch) step-by-step and even gives full MATLAB-code. From the abstract: ...


11

Instead of wild guesses about R's/python's future in the community, here some facts: The following query on StackExchange Data Explorer counts the number of questions that have <r> or <python> tags. If you scroll down on one of the three webpages provided below, you can see a graph with data on a monthly basis. You can easily run this query on ...


10

Nick Higham happens to have given a talk on this very subject this summer; he continues to actively work to improve nearest correlation matrix algorithms. You can see his talk and notes here: http://mxm.mxmfb.com/rsps/ct/c/629/r/90368/l/48110


9

Before I try to answer your question we need to establish a difference between what one wants to analyse. It is true that before modern time-series methodologies were developed, researches used "correlation" between prices as a means of analysis. However, since a Price (at a specific moment in time) is 1 value, it makes no sense to compare 2 prices with ...


9

The $R^2$s are usually close to zero for single stock regressions. The big $R^2$s that a lot of asset pricing research shows is by forming portfolios. Forming portfolios cancels a lot of the idiosyncratic returns, which has a smoothing effect. The $R^2$s should be low here, although I don't see any in the paper for you to compare. This probably means they ...


9

From Quantitative Trading by Ernie Chan : "Correlation between two price series actually refers to the correlations of their returns over some time horizon (for concreteness, let's say a day). If two stocks are positively correlated, there is a good chance that their prices will move in the same direction most days. However, having a positive correlation ...


9

Treat the estimate of standard deviation as a random variable. Then you can bootstap the sample estimate and generate t-statistics and associated confidence intervals for your statistics. I describe a generic boostrap process on this post.


9

A simple google search should get your started: I like this one the best because it compares different packages: http://stat-www.berkeley.edu/~brill/Stat248/kalmanfiltering.pdf and here couple more: http://www.r-bloggers.com/the-kalman-filter-for-financial-time-series/ http://cran.r-project.org/web/packages/dlm/index.html ...


8

You are correct: evaluating volatility forecasts is quite different from evaluating forecasts in general, and it is a very active area of research. Methods can be classified in several ways. One criterion is to consider evaluation methods for single forecasts (e.g., for the time series of returns of a specific portfolio) vs multiple simultaneous forecasts ...


8

Let us test that $x$ and $y$ are co-integrated, say that $x_t, y_t \sim I(1)$. In the Engle-Granger we test stationarity of the error term in $$y_t = \alpha + \beta x_t + u_t$$ which we estimate as $$\hat u_t = y_t - \hat \alpha - \hat \beta x_t$$ and find that $\hat \alpha =0$, $\hat \beta = 1$, and $\hat u_t = 0 \; \forall t$. So now when we Dickey-Fuller ...


8

The somewhat tongue-in-cheek blog post http://www.portfolioprobe.com/2010/10/18/american-tv-does-cointegration/ includes the example of two classes of shares on the same company. In this case you have two assets that are essentially the same but with a few details different. The buying and selling of these assets will make the prices fluctuate from each ...


8

Why don't you try it and report back? Recall, though, that while a random walk is often a rather competitive forecast, realized data is understood to have weak dependence especially in higher moments. Having worked a bit with DieHarder, I'd suspect it to reject a number of series. But the proof is in the pudding...



Only top voted, non community-wiki answers of a minimum length are eligible