Hello everyone,
I have been spending many hours on a seemingly simple portfolio optimization
problem using the package fPortfolio.
My optimization problem is slightly different than a standard one such that I
have a known set of asset returns. My problem is how to collect this information
into my functions and pass them onto the optimization function.
I have written my own covariance estimation function using the
"shrinkEstimator" as template. I will use the shrunk estimation of the
covariance matrix with my own set of predicted returns. My code is below.
Many thanks,
Darius
-----------------------------------------------------------------------
b=ts(ret.forecast[1,])
mu.pred=b
myEstimator=function(x)
{
stopifnot(inherits(x, "timeSeries"))
x.mat = x
mu = mu.pred
Sigma = .cov.shrink(x = x.mat, verbose = FALSE, ...)
attr(Sigma, "lambda.var") <- NULL
attr(Sigma, "lambda.var.estimated") <- NULL
list(mu = mu, Sigma = Sigma)
}
portfolio1=portfolioSpec()
a=ts(ret.mat[(1:60),(1:n.assets)])
setEstimator(portfolio1)="myEstimator"
portfolio2=tangencyPortfolio(data=a, spec=portfolio1)
[[alternative HTML version deleted]]