[R-SIG-Finance] fPortfolio, frontierSlider, weightsSlider

John P. Burkett burkett at uri.edu
Fri Jul 31 19:59:36 CEST 2009


Brian G. Peterson wrote:
 > John P. Burkett wrote:
 >> The package fPortfolio, when I used it a year ago, included a 
function frontierSlider, which worked well for me.  Judging by the April 
20, 2009 reference manual for fPortfolio, the old frontierSlider 
function has been replaced by a new weightsSlider function.
 >>
 >> My attempt to follow the example on p. 57 of the reference manual 
goes as follows:
 >> > Data = SMALLCAP.RET
 >> > Data = Data[, c("BKE", "GG", "GYMB", "KRON")]
 >> > frontier = portfolioFrontier(Data)
 >> > weightsSlider(frontier)
 >> Error in getTargetRisk(object)[, 1] : incorrect number of dimensions
 >>
 >> My attempts to use weightsSlider with my own data end with the same 
error message.
 >>
 >> Can anyone diagnosis the error message and/or suggest how to produce 
an interactive portfolio weights plot?
 >>
 >> -John
 >>
 >>
 >
 > Here's how to diagnose the problem and gather more information to 
share with the list:
 >
 >  >debug(weightsSlider)
 >  >weightsSlider(frontier)
 >
 > step through the function,
 > examine what it is doing. Go all the way to the failure point once.
 > Do it again, but this time pay attention as you get close to the 
failure point. Collect data to share here on the data being passed into 
the bit (getTargetRisk) that fails.
 > Examine what the getTargetRisk function normally expects.

Thank you, Brian, for your good suggestions. My attempt to use debug and 
the results are as follows:

 > debug(weightsSlider)
 > weightsSlider(frontier)
debugging in: weightsSlider(frontier)
debug: {
     object <<- object
     nFrontierPoints <- length(getTargetRisk(object)[, 1])
     dim = dim(getWeights(object))[2]

<snip>

         starts = c(Start))
     invisible()
}
Browse[1]> n
debug: object <<- object
Browse[1]>
debug: nFrontierPoints <- length(getTargetRisk(object)[, 1])
Browse[1]>
Error in getTargetRisk(object)[, 1] : incorrect number of dimensions
 >

Trying to learn what the getTargetRisk function normally expect, I did
?getTargetRisk
eliciting the following response:
getDefault            package:fPortfolio            R Documentation
Extractor Functions
Description:
      Extractor functions to get information from objects of class
      fPFOLIODATA, fPFOLIOSPEC, fPFOLIODATA, fPFOLIOVAL, and fPORTFOLIO.
Usage:
      getConstraints(object)
<snip>
      getTargetRisk(object)
<snip>
Arguments:
   object: an object of class 'fPFOLIODATA', 'fPFOLIOSPEC' or
           'fPORTFOLIO'.
      ...: optional arguments to be passed.

Doing "getTargetRisk" got this response:
function (object)
{
     UseMethod("getTargetRisk")
}
<environment: namespace:fPortfolio>

I'd be grateful for help in interpreting the above results and/or 
suggestions for obtaining more information.

Best regards,
John

-- 
John P. Burkett
Department of Economics
University of Rhode Island
Kingston, RI 02881-0808
USA

phone (401) 874-9195



More information about the R-SIG-Finance mailing list