[R] Calculate a minimum-variance portfolio with fPortfolio

varcovar varcovar at live.com
Tue Sep 4 18:00:08 CEST 2012


Hello everybody, 

I'm running into an issue with the fPortfolio package. 

1. What I want: 
Calculate the minimum-variance portfolio on 20 assets with respect to the
following constraints: 
- min weight per asset = 0% (i.e. no short-selling)
- max weight per asset = 10% 
- min sum of asset weights = 100% (i.e. fully invested)
- max sum of asset weights = 100% (i.e. no leverage)

2. What I get: 
Execution stopped:
  The minimum risk portfolio could not be computed.
Possible Reason:
  Your portfolio constraints may be too restrictive.
Status Information:
  status=1 from solver solveRquadprog.
Error: 
  returned from Rmetrics

3. Why I don't understand this error: 

Well, I don't know. The constraints seem good since I would be able to
construct an equal-weighted portfolio that satisfies all of them (e.g. with
5% in each asset). 

4. Reproducible example: 

library(fPortfolio)

# Data
data <- SMALLCAP[, 1:20]

# Constraints
box.1 <- paste0("minW[1:nAssets] = ", 0)
box.2 <- paste0("maxW[1:nAssets] = ", 0.10)
box.3 <- "maxsumW[1:nAssets] = 1"
box.4 <- "minsumW[1:nAssets] = 1"
boxConstraints <- c(box.1, box.2, box.3, box.4)

# Portfolio Specs
Spec <- portfolioSpec()

# Calculate MinVar Portfolio
minvar <- minvariancePortfolio(
    data = data, 
    spec = Spec, 
    constraints = boxConstraints)

5. Thanks a lot for your help! 

Markus Douglas, Jr. 



--
View this message in context: http://r.789695.n4.nabble.com/Calculate-a-minimum-variance-portfolio-with-fPortfolio-tp4642188.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list