[R-SIG-Finance] fPortfolio
Bastian Offermann
bastian2507hk at yahoo.co.uk
Thu Dec 11 02:44:09 CET 2008
Nobody?? I am wondering what the problem is. Using different inputs for
setRiskFreeRate(Spec) I always get the same output (i.e. same weights).
And there is never an allocation to the riskfree asset no matter what my
required return is? Where is my mistake? Am I totally wrong here??
Thanks.
Regards
B
Hello,
i have encountered a problem with fPortfolio recently. I am using below
code:
the problem is that my risk free rate is different from the one
displayed in the graphical output and the straight line in the graphical
output intersects the efficient frontier twice. same problem when i use
"cmlLines(eff.front)" .what am i missing out on?
THanks.
Data1 <- as.timeSeries(Data1)
Data1 <- as.timeSeries(data(LPP2005REC))
Data1 <- Data1[,1:4]*250
r.p <- 0.10
r.rf <- 0.01
Spec <- portfolioSpec()
restr <- c("Short", "LongOnly")
cons <- restr[1]
setOptimize(Spec) <- "minRisk"
setRiskFreeRate(Spec) <- r.rf #/250
setTargetReturn(Spec) <- r.p #/250
setNFrontierPoints(Spec) <- 50
solver <- c("solveRquadprog", "solveRshortExact")
if(cons == "LongOnly") { setSolver(Spec) <- solver[1] }
if(cons == "Short") { setSolver(Spec) <- solver[2] }
eff.front <- portfolioFrontier(data = Data1, spec = Spec, constraints =
cons)
eff.port <- efficientPortfolio(data = Data1, spec = Spec, constraints =
cons)
tang.port <- tangencyPortfolio(data = Data1, spec = Spec, constraints =
cons)
minvar.port <- minvariancePortfolio(data = Data1, spec = Spec,
constraints = cons)
w <- as.vector(getWeights(eff.port))
w <- matrix(w, 1, ncol(Data1))
w.min <- as.vector(getWeights(minvar.port))
w.min <- matrix(w.min, 1, ncol(Data1))
w
w.min
frontierPlot(eff.front, frontier = "upper", return="mu", risk="Sigma",
type="l")
minvariancePoints(eff.front, col="red", bg="red", pch=21)
tangencyLines(eff.front)
tangencyPoints(eff.front)
More information about the R-SIG-Finance
mailing list