[R-SIG-Finance] Constraints on tangecyPortfolio in fPortfolio
Ledon, Alain
Alain.Ledon at ally.com
Tue Apr 10 22:11:15 CEST 2012
Did you try passing the constraint directly into "tangencyPortfolio"?
> library(fPortfolio)
> lppData <- 100 * LPP2005.RET[, 1:6]
> tgSpec <- portfolioSpec()
> setRiskFreeRate(tgSpec) <- 0
> tgPortfolio <- tangencyPortfolio(data=lppData, spec=tgSpec, constraints="LongOnly")
> tgPortfolio)
> tgPortfolio <- tangencyPortfolio(data=lppData, spec=tgSpec, constraints="minW[1:6]=0.01")
> tgPortfolio
Alain
(646)781-2698
-----Original Message-----
From: r-sig-finance-bounces at r-project.org [mailto:r-sig-finance-bounces at r-project.org] On Behalf Of Noah Silverman
Sent: Monday, April 09, 2012 9:08 PM
To: Brian G. Peterson
Cc: r-sig-finance at r-project.org
Subject: Re: [R-SIG-Finance] Constraints on tangecyPortfolio in fPortfolio
Brian,
I appreciate the suggests, however that isn't the issue.
The "c" is from the example in the rmetrics book.
Removing it doesn't change the results at all.
Additionally, I am using the portfolioConstraints function.
--
Noah Silverman
UCLA Department of Statistics
8208 Math Sciences Building
Los Angeles, CA 90095
On Apr 9, 2012, at 5:59 PM, Brian G. Peterson wrote:
> 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
>
[[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.
More information about the R-SIG-Finance
mailing list