[R-SIG-Finance] [R-sig-finance] rmetrics portfolio backtesting limitations question

spencerg spencer.graves at prodsyse.com
Mon Jul 13 01:57:23 CEST 2009


Hello, Andrew: 


      I'm not familiar with either "portfolioBacktest" nor 
"setWindowsHorizon".  Moreover, using RSiteSearch produced nothing for 
either.  You might get more help from this list if you don't require 
respondents to understand these terms. 


      Have you considered using the "debug" function to walk through 
code line by line, looking at what it does, changing things at will?  
You can often learn enough doing this to see what you need to do to get 
it to do what you want, provided there is enough information in the 
data.  By doing this, you should be able to get the weights outputted in 
many different ways. 


      However, I'd look carefully at any algorithms that produced 
distinct portfolio weights for many assets.  As a check, I suggest you 
compute "eigen" of "corr" on your favorite 50 assets and look at 
"eigen(...)$values".  If the smallest eigenvalue exceeds, say, 0.0001 
times the largest, you are probably OK.  Otherwise, your use of 
individually estimated weights could be worse than using constant 
weights. In particular, if you have fewer than 50 observations, the 
smallest eigenvalue may be negative, which says that that portion of the 
variability, and probably more than that, is driven by round-off error.  
I'd rather not base investment decisions on round-off. 


      Hope this helps. 
      Spencer Graves
p.s.  Are you aware that you can get the source code for any CRAN 
package?  For example, the source for the "timeDate" package is 
available in a file "timeDate_290.85.tar.gz" downloadable from 
"http://cran.fhcrc.org/web/packages/timeDate/index.html".  If the people 
who wrote a particular functions included comments in their code, they 
will appear in the *.tar.gz file but not in the version you get by 
typing the function name. 


tradenet wrote:
> I have been working with the portfolioBacktesting function in Rmetrics and it
> seems to be a very powerful and useful function.  There seems to be some
> limitations/bugs that seriously limits the utility of the function and I was
> hoping someone has found workarounds:
>
> 1.) If I specify a large number of assets, say 50, in the formula, e.g. SPX
> ~ asset1 + asset2....+asset50
> then it seems only the first 29 assets are used in the analysis. 
> ncol(backtestPortfolios$weights) always returns 29 and assets near the end
> of the list get nonzero weights if I move their names to the beginning of
> the formula string, otherwise those assets do not appear in the results.  Is
> there a way to NOT compare results to a benchmark?  I'd like to just supply
> a timeseries of asset returns for a date range and run the analysis using
> all assets in the timeseries as portfolio candidates.
>
> BTW, if anyone knows an easy way to dump out the weights to a file I'd
> appreciate the insight
>
> 2.) the 12m window horizon seems to be the only one that works:
> setWindowsHorizon(backtestBT)<-"12m" works, but <-"3m" yields an error
> message.
>
> I thought this might have to do with the lambda smoothing, so I set the
> smoothing to "1m" and still no go
>
> 3.) does anyone know how to turn smoothing completely off?  I would like to
> see the raw, unsmoothed weights
>
> 4.) is there anyway to plot the results without performing weight smoothing
> -- I don't want to have to do smoothing to look at all the great plots and
> results.
>
> Rmetrics is great stuff, so close to being beyond perfect!  I am very
> grateful to the developers and the community.
>
> Warm regards,
>
> Andrew
>



More information about the R-SIG-Finance mailing list