[R-SIG-Finance] Constraints on tangecyPortfolio in fPortfolio

Brian G. Peterson brian at braverock.com
Tue Apr 10 02:59:42 CEST 2012


I don't really use fPortfolio much, except for comparison, and I never
use the function tangencyPortfolio, but the Portfolio Optimization with
R/Rmetrics book suggests that you should be using the
portfolioConstraints function.  It also seems that your use of the c()
operator is misplaced, creating a character vector of what should be a
string.


On Mon, 2012-04-09 at 17:47 -0700, Noah Silverman wrote:
> Hi,
> 
> I'm using fPortfolio to analyze some equities.  It works well.
> 
> mySpec <- portfolioSpec()
> myPort <- tangencyPortfolio(thisHist, mySpec)
> 
> 
> I was asked to include a constraint that each stock gets at least 1% of the allocation.
> 
> Following the documentation for fPortfolio fails
> 
> mySpec <- portfolioSpec()
> constraints <- c("minW[1:portSize]=0.01")
> myConst <- portfolioConstraints(thisHist, mySpec, constraints)
> myPort <- tangencyPortfolio(thisHist, mySpec, myConst)
> 
> The error is rather cryptic:
> 
> Error in as.character.default(x) : 
>   no method for coercing this S4 class to a vector
> 
> 
> Does anyone have any suggestions?
> 
> 
> 
> --
> Noah Silverman
> UCLA Department of Statistics
> 8208 Math Sciences Building
> Los Angeles, CA 90095
> 
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list