[R-SIG-Finance] fPortfolio error

Yohan Chalabi chalabi at phys.ethz.ch
Wed Nov 19 18:02:26 CET 2008


>>>> "AM" == "Attiglah, Mama" <Mama_Attiglah at ssga.com>
>>>> on Fri, 14 Nov 2008 14:58:25 -0000

   AM> Hi All,  
   AM> I have been trying to use some of the Rmetrics packages to do some quick analysis but experiencing a pb of flexibility that I willl explain below by the package own example. 
   AM> 
   AM> 1) 
   AM> #   Data = as.timeSeries(data(smallcap.ts))
   AM>    Data = Data[, c("BKE", "GG", "GYMB", "KRON")]
   AM>    Data
   AM>    Spec = portfolioSpec()
   AM>    Spec
   AM>    setTargetReturn(Spec) = mean(colMeans(Data))
   AM>    Constraints = "LongOnly"
   AM> 
   AM> Ans = minvariancePortfolio(Data, Spec, Constraints)
   AM> 
   AM> In the optimisation, the historical mean and cov matrix 
   AM> i.e
   AM>        BKE         GG       GYMB       KRON 
   AM> 0.02749712 0.02198486 0.01204526 0.03570639 
   AM> and 
   AM>               BKE           GG         GYMB         KRON
   AM> BKE   0.022526377 -0.003495562  0.010318065  0.007935904
   AM> GG   -0.003495562  0.036070945 -0.003806943 -0.006872127
   AM> GYMB  0.010318065 -0.003806943  0.049574959  0.008098270
   AM> KRON  0.007935904 -0.006872127  0.008098270  0.028025520
   AM> are input. 
   AM> 
   AM> 
   AM> 1) My question is this: Is there anyway I can change any of those two inputs statistics computed from the historical data before feeding the optimizer, for instance if I have a different expectation of the future? 
   AM> In order words, in case I don't have the historical data but do have the expected returns and covariance matrix, can I still ran the optimiser? 
   AM> 


if you have exptected return you could do something like 
rbind(historical return, exptected return) 

or pass your own calculated covariance matrix with

setEstimator(Spec) <- "yourNewCovEstimator"

and use covEstimator as a template to write "yourNewCovEstimator". (?covEstimator)

   AM> 2) The target return set and the resulting portfolio returns coming from the optimal weights are different by 22 basis points. Is that due to the algorithm of solveRquadprog ? 
   AM> 


I think there is some confusion between 'efficientPortfolio' and
'minvariancePortfolio' functions. The former function calculates the most
efficient portfolio for a given level of return, in the case of risk
minimization, and 'minvariancePortfolio' optimizes the weights over a range
of target returns to reach the minimal variance portfolio.

Thus
setTargetReturn(Spec) = mean(colMeans(Data)) 
is only meaningful with 'efficientPortfolio' function.

   AM>            mean    
   AM> [1,] 0.02651604 
   AM> > Spec  
   AM> 
   AM> Portfolio Specification:        
   AM>  Portfolio Type:            MV
   AM>  Optimize:                  minRisk
   AM>  Covariance Estimator:      covEstimator
   AM>  Target Return:             0.02430841
   AM>  Portfolio Risk-Free Rate:  0
   AM>  Number of Frontier Points: 50
   AM>  Optimizer:                 solveRquadprog 
   AM> 
   AM> 
   AM> Regards 

-- 
PhD student
Swiss Federal Institute of Technology
Zurich

www.ethz.ch



More information about the R-SIG-Finance mailing list