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!