S&P 500 Returns

[This article was first published on mickey mouse models, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I’ll begin with a familiar image:

That plot shows the closing values of the S&P 500 index from 1990 until today. It’s a useful representation — at a glance, you can tell when the market rose and fell. That said, it does have some problems: we’re looking at absolute movements in the index, when we really care about relative changes. We don’t want the early 1990s to be dwarfed by the 2000s, so let’s take a look at daily logarithmic returns:

Much better! I find this plot extremely interesting. Each point shows the logarithmic returns from holding the index close-to-close until the next trading day. The return volatility appears to vary dramatically: the mid-1990s and mid-2000s were calm; 2008 was extremely turbulent. I didn’t see that in the first plot, but now it’s quite clear.

Let’s continue with a plot of the 200-day running mean of logarithmic returns. If you bought the index on a given day, what average logarithmic returns would you have seen across the next 200 trading days? Look below:

Are the S&P 500 returns i.i.d.? At a glance, I would say no, since the mean and variance both appear to change across time. I’m sure this can be tested statistically, but I would much prefer to look at these plots!

Here’s my code; suggestions and comments welcome.

# Yahoo finance url for S&P 500 data

To leave a comment for the author, please follow the link and comment on their blog: mickey mouse models.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)