Skip to content

correlation between two stock market indices

3 messages · Pfaff, Bernhard, Ajay Shah, Dirk Eddelbuettel

#
well, here you are superimposing the validity of a 
hypothesis, that should be checked first. By using 
differenced data you are almost always on the *safe side*, 
but again you are giving up the information content of the 
series in levels. This can be circumvented by specifying an 
ECM. Furthermore, you might want to use log data, i.e. a 
transformation that stabilises the variance. As a side effect 
the lm() estimated coefficients can be interpreted as 
elasticities, i.e. the responsiveness of your lhs-variable to 
a unit change of your rhs-variable (in levels).
yes, and this tells you the order to specify for arma(), 
given a stationary series:

ar(p): slowly decaying acf (or dampening alternating in case 
of negative ar coeffcient) and a spike at p in the pacf.

ma(q): just like ar(p), but the shape of acf and pacf are 
reversed, i.e. single peak in the acf and slowly decaying 
pacf (or dampening alternating in case of negative ma coeffcient).

HTH,
Bernhard
--------------------------------------------------------------------------------
The information contained herein is confidential and is inte...{{dropped}}
#
You can go far with short R code fragments, such as :

     library(its)
     x1 <- priceIts(instrument=c("^ftse"), start="1998-01-01", quote = "Close")
     x2 <- priceIts(instrument=c("^gdax"), start="1998-01-01", quote = "Close")
     prices <- intersect(x1,x2)
     names(prices) <- c("FTSE","DAX")
     returns = 100*diff(log(prices))
     cor(returns)

which gives 

          FTSE       DAX
FTSE 1.0000000 0.7455468
DAX  0.7455468 1.0000000

so you see that returns on the FTSE and the DAX have had a correlation
of 0.7455 in the post-1998 period.

I think the above serves as a great demo of R and 'its' in action! :-)

The pitfalls:

  * Timezones matter greatly. If one market closes before another,
    then it will look like one is causing the other, if viewed through
    daily returns.

    So you have to either go 'in' and pick intervals when both markets
    are contemporaneously trading, or you have to zoom 'out' and pick
    fat intervals where the overlaps matter less.

    E.g. India and the US have exactly non-overlapping hours. I find
    it hard to meaningfully interpret correlations of contemporaneous
    or lagged returns of daily data. It makes more sense to discuss
    correlations of weekly data.

  * Be careful to intersect and then compute returns, as done
    above. Be careful to make returns as 100*diff(log(prices)), as
    done above.

  * R TODO:
    The code fragment above works for indexes but not for individual
    stocks, since priceIts does not know how to give us "adjusted
    closing prices". That is, when splits take place, the price gets
    clobbered, and the series generated by priceIts is useless. I
    would be very happy if people on this list are able to propose a
    solution. I think priceIts is fabulous but this is a major gap in
    functionality. Raw closing prices are next to useless since most
    finance starts with returns, and in order to make returns, we need
    adjusted closing prices.

  * Markets are quite efficient for individual products (e.g. index
    futures or stocks) and you don't generally have problems with
    time-series structure. But when you get to indexes, the process of
    making linear combinations of things that trade with different
    timestamps is known to induce suprious autocorrelations. Andy Lo
    and others have papers on this. This problem is particularly acute
    when an index contains illiquid products.

  * Even if you dealt with individual traded products, like stocks or
    index futures, you'd have the problem of time-varying
    correlations.  You can do rolling window correlations and they'll
    help.

    R TODO: 
    There isn't yet a bivariate ARCH implementation in CRAN or in the
    Debian packages.

    R TODO:
    There isn't yet an abstract engine doing rolling window estimation
    in R, where you get to define the estimator (e.g. as is the case
    with 'by' where you get to specify FUN).
#
On Tue, Aug 31, 2004 at 10:12:51AM +0530, Ajay Shah wrote:
get.hist.quote(0 in tseries was written before Yahoo! added that fifth
column of adjusted values. priceIts() is a pretty straight copy of
get.hist.quote().

If you submit a decent patch to either one, including an update to the .Rd
file, I am sure that it will get integrated into the package in due course.

Dirk