I’ve been trying to learn R, and I’ve done graphs and charts with it, for such tasks as comparing the performance of mutual funds, and just now I finally got around to doing a basic regression: I took some data from Yahoo Finance, and did a regression of the adjusted returns of a particular stock, (PCP it happened to be,) against those of SPY as a proxy for the S&P 500. So I estimated the beta of a stock. Pretty basic, nothing special, but I’m hoping that R will help me learn some of the ins and outs of multiple regression, heteroskedasticity, serial correlation, and multicollinearity for the exam.
I’m thinking these concepts will stick a little better in my mind if take some actual data, play with it, adapt the examples in the readings to the data I have on hand, and actually work through them.
I have fiddled around with R aswell although i have not done anything for more than a month already…can’t be arsed these days. There are many great free resources for R…most notably r-bloggers.com.
Once I got over some of the mechanics it was easier than I thought. I wrote a function to construct the url to fetch some data from yahoo finance (ignore the hyperlink—why don’t my pre tags work on this forum?):
yurl
given a symbol and date range. Now I can call, for example,
SPY
and without further ado, R will fetch the data directly from Yahoo Finance into a data frame where I can work with it. R has a powerful syntax for specifying any kind of model you want for the regression. Not only that, but tests like Durbin–Watson, Breusch–Pagan, you name it, R either does it out of the box, or there is an R library to do it. Never mind if you can’t be a**ed; I just can’t keep all this stuff from the book straight in my mind if I don’t play with it a little at least so I can say “oh, yeah, this what that test does, and this what it’s for” before I move on.
Thanks. I actually wrote that function previously to pull a bunch of data to make a performance comparison chart of mutual funds for a 401k platform, (decisions, decisions…) and I wasn’t even thinking of doing anything quantish with it. I’ve heard of the quantmod package, but I didn’t know it was customised for various data sources.
In any case, my first goal is to become conversant with the fundamental stats concepts in the reading, and I was trying to be creative and do something “practical” to reinforce my book-learning. I was thinking of experimenting with, say to begin with, “bptest” and “dwtest” in the lmtest package. (And nothing fancy: just reading the documentation helps me remember what they are, and all I want to do is see what these tests do on some actual data.) Once I’ve got the basic stats down pat for the test, and I have loads of time to … fart around … between work and study, family and friends, getting enough sleep, etc. etc. then I’ll move on and have fun with quantmod.