Problem with Portfolio Optimization, Mean Returns are not processed as vectors
显示 更早的评论
Hey everybody,
I am trying to implement a classical portfolio optimization à la Markowitz with financial tooldbox. The data input is according to the following: (a 660x500 matrix)
Asset1 Asset2 Asset3 Asset4 ...... Asset500
1960_01
1960_02
...
...
2014_12
the entries are monthly returns in that specific slot.
Now I try to perform the calculation of the efficient frontier using the Portfolio commands: First I cut the size of the set into intervals (later it will be in a for loop, for now I am trying to create a interval of the first 60 months):
ret_temp = ret(1:60,:); %subset of the dataset
.
Now, I am calculating the mean return and the var/cov matrix for each asset in this subpart:
mean_temp = nanmean(ret_temp); %returns a vector of mean returns of each asset cov_temp = nancov(ret_temp); %var/cov matrix of the sample period
now I can perform a portfolio optimization based on these inputs:
p = Portfolio; p = setAssetMoments(p,mean_temp,cov_temp); p = setDefaultConstraints(p); pwgt = estimateFrontier(p, 10);
Now, when running the code, the following Error appears:
Error using codename (line 18) Cannot set moments of asset returns.
Caused by: Error using Portfolio/parsearguments (line 101) Invalid AssetMean must be a scalar or a vector.
However, my asset means are clearly a vector and I cannot understand why this error is popping up..
Thank you very much in advance!
Clemens
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Portfolio Optimization and Asset Allocation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!