[R-SIG-Finance] Problem with solver solveRquadprog in fPortfolio
Peter Keller
podvalov at gmx.net
Sat Apr 17 14:33:43 CEST 2010
Yes, it almost works, and I had "quadprog" already installed.
Unfortunately, after calling in my example (top post):
...
Spec <- portfolioSpec()
setSolver(Spec) <- "solve.QP"
frontier <- portfolioFrontier(djiData.ret, Spec)
I get now the error message:
Error in rep(0, q) : invalid 'times' argument
Tricky thing... Any idea what is the reason for that and how to solve
it? Or better wait for new release of fPortfolio?
Kind regards,
Peter
Sarbo wrote:
> Try this:
>
> library(quadprog)
>
> Spec <- portfolioSpec()
> setSolver(Spec) <- 'solve.QP'
>
> "solve.QP " is the solver used by the "quadprog" package, but I suspect
> you need to have the package loaded already in order for this to work.
> However, since quadprog is part of the base R installation anyway, I
> doubt you'll need to install it.
>
> On Sat, 2010-04-17 at 15:08 +0300, Peter Keller wrote:
>> Thanks for the suggestion. I already tried to change the solver in
>> fPortfolio, but I was not yet successful.
>>
>> As far as I know, you can change the solver in fPortfolio as follows:
>>
>> ...
>> Spec <- portfolioSpec()
>> setSolver(Spec) = "solveRquadprog"
>> ...
>>
>> But this exactly leads to the Fortran error (because it's using package
>> "Rglpk"?)... So, how do I change the solver with setSolver(Spec) to use
>> package "quadprog" correctly?
>>
>> Unfortunately I did not find the correct function call in the fPortfolio
>> eBook...
>>
>> Thanks for your help in advance,
>>
>> Peter
>>
>> Sarbo wrote:
>> > In the meantime, why not use the "quadprog" package instead? It's pretty
>> > much the same thing, you just have to be a little more careful in
>> > setting out the optimisation problem.
>> >
>> > On Sat, 2010-04-17 at 14:33 +0300, Peter Keller wrote:
>> >
>> >> Yohan,
>> >>
>> >> First of all thank you very much for your fast reply and clarification.
>> >> I thought it could be an interface error, but of course I was not sure.
>> >>
>> >> Do you have already a rough idea when the new version of fPortfolio will
>> >> be released?
>> >>
>> >> Have a nice weekend and best regards,
>> >>
>> >> Peter
>> >>
>> >> Yohan Chalabi wrote:
>> >>>>>>> "PK" == Peter Keller <podvalov at gmx.net <mailto:podvalov at gmx.net>>
>> >>>>>>> on Sat, 17 Apr 2010 14:07:29 +0300
>> >>> PK> Hi there,
>> >>> PK>
>> >>> PK> I have a serious problem with solver solveRquadprog in
>> >>> PK> fPortfolio.
>> >>> PK> Unfortunately, solveRquadprog is the standard solver in
>> >>> PK> fPortfolio and
>> >>> PK> pretty essential.
>> >>> PK>
>> >>> PK> How to replicate the problem on my PC:
>> >>> PK>
>> >>> PK> library(fPortfolio)
>> >>> PK> library(fEcofin)
>> >>> PK>
>> >>> PK> library(Rsymphony)
>> >>> PK> library(lpSolveAPI)
>> >>> PK>
>> >>> PK> djiData = as.timeSeries(DowJones30)
>> >>> PK> djiData.ret <- 100 * returns(djiData)
>> >>> PK> frontier <- portfolioFrontier(djiData.ret)
>> >>> PK>
>> >>> PK> I get then the error message:
>> >>> PK>
>> >>> PK> Error in .Fortran("qpgen2", as.double(Dmat), dvec =
>> >>> PK> as.double(dvec),
>> >>> PK> as.integer(n), :
>> >>> PK> Incorrect number of arguments (16), expecting 17 for qpgen2
>> >>> PK>
>> >>> PK> I’ve installed R version 2.10.1 on Windows 7 (32 bit) with
>> >>> PK> updated CTV
>> >>> PK> Finance.
>> >>> PK>
>> >>> PK> Interestingly, this problem only appeared after a
>> >>> PK> while. Initially,
>> >>> PK> everything worked fine, but suddenly, without doing something
>> >>> PK> special,
>> >>> PK> this error appeared. I already completely uninstalled R,
>> >>> PK> rebooted the PC
>> >>> PK> and re-installed R (including updated CTV Finance), but it
>> >>> PK> did not help
>> >>> PK> at all.
>> >>> PK>
>> >>> PK> I highly would appreciate any help. I already spent quite a
>> >>> PK> lot of time
>> >>> PK> to find a solution, but there is not a lot of help available.
>> >>> PK>
>> >>> PK> Best regards,
>> >>> PK>
>> >>> PK> Peter Keller
>> >>>
>> >>>
>> >>> Hi Peter,
>> >>>
>> >>> The mentioned error is due to a change in the new version of
>> >>> quadprog package and a direct call of the Fortran routine in fPortfolio.
>> >>>
>> >>> We have already updated the devel version of fPortfolio on R-forge. As
>> >>> soon as we have run all test, we will upload a new version of
>> >>> fPortfolio to CRAN.
>> >>>
>> >>> You can either wait until the new pkg is on CRAN or compile it from
>> >>> source and get the devel code from R-forge. More info
>> >>> http://r-forge.r-project.org/scm/?group_id=156
>> >>>
>> >>> Regards,
>> >>> Yohan
>> >>>
>> >>>
>> >> _______________________________________________
>> >> R-SIG-Finance at stat.math.ethz.ch <mailto:R-SIG-Finance at stat.math.ethz.ch> 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.
>> >
>> >
>> >
>> > [[alternative HTML version deleted]]
>> >
>> >
>> >
>> > ------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > R-SIG-Finance at stat.math.ethz.ch <mailto:R-SIG-Finance at stat.math.ethz.ch> 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