Tuesday, August 7, 2012

48 Industries Since 1963

Please see http://timelyportfolio.blogspot.com/search/label/horizonplot for all horizon plot posts.

Once more thanks to Ken French for his data, we can accomplish something I think is fairly amazing.  In 640x800, we can see 250 day rollling returns for 48 U.S. industries since 1963.

From TimelyPortfolio

R code in GIST (do raw for copy/paste):

6 comments:

  1. I have noticed a small issue with your script, perhaps you are developing on Windows but in Linux and other *NIX systems, that path does not work with those slashes but needs to be /


    So, instead of:

    #this will be the temp file set up for the zip file
    my.tempfile<-paste(tempdir(),"\\frenchindustry.zip",sep="")
    #my.usefile is the name of the txt file with the data
    my.usefile<-paste(tempdir(),"\\48_Industry_Portfolios_daily.txt",sep="")


    It should be this for support on other platforms like Linux and OS X etc:


    #this will be the temp file set up for the zip file
    my.tempfile<-paste(tempdir(),"/frenchindustry.zip",sep="")
    #my.usefile is the name of the txt file with the data
    my.usefile<-paste(tempdir(),"/48_Industry_Portfolios_daily.txt",sep="")


    Thanks for the useful guide
    Cheers,

    Mohomed

    ReplyDelete
  2. thanks so much for pointing this out in your helpful comment. thanks for reading.

    ReplyDelete
  3. I think it would be interesting to see the industries ordered by some sort of similarity of returns.

    ReplyDelete
    Replies
    1. I agree so I did in this post http://timelyportfolio.blogspot.com/2012/08/48-industries-dendrogram-ordered-over.html

      Delete
  4. While running this line:

    french_industry_xts <- as.xts(french_industry[,1:NCOL(french_industry)], order.by=as.Date(datestoformat,format="%Y-%m-%d"))

    I get this error:

    Error in as.POSIXlt.character(x, tz, ...) :
    character string is not in a standard unambiguous format

    ReplyDelete
    Replies
    1. I changed it to

      french_industry_xts <- as.xts(french_industry[,1:NCOL(french_industry)],
      as.POSIXct(datestoformat,format="%Y-%m-%d"))

      and it's all OK.

      Delete