Skip to content
Prev 2345 / 15274 Next

Direct Specification of Mu and Sigma in fportfolio

reini <reinhold.hafner at risklab.de> writes:
Hi Reini,

we are currently working on an update of the fPortfolio package. Many
new features will become available, like LPM optimization, and second
order cone programming in a separate package.

We are trying to make fPortfolio as modular as possible to help users to
defined their own functions.

The "unfinished" manual page of portfolioSpec describes how to do it.

a quick example :

--------------

library(fPortfolio)
# only with development version of fPortfolio available on R-Forge

# now you can define your own estimator which must returns a list with a
# named list, with at least the following two entries '\$mu' and
# '\$Sigma', which represent estimators for the mean and covariance,
# respectively.
myEstimator <- 
    function(x, spec = NULL, ...) list(mu = colMeans(x), Sigma = cov(x))

Spec <- portfolioSpec() # default portfolio specification  
setEstimator(Spec) <- "myEstimator" # new estimator
Spec

# Load Data and Convert to timeSeries Object:
Data = as.timeSeries(data(smallcap.ts))
Data = Data[, c("BKE", "GG", "GYMB", "KRON")]
Data

## Compute properties of Efficient Portfolio
frontier <- portfolioFrontier(Data, Spec, "LongOnly")
plot(frontier)

--------------

you can download the latest development version from our R-Forge project
page at http://r-forge.r-project.org/projects/rmetrics/. But bear in
mind that this is a development version... if you have any suggestion to
improve the package, do not hesitate to send us your feedback!

all my apologises for the late response,
Yohan