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 660×500 matrix)
Asset1 Asset2 Asset3 Asset4 ...... Asset5001960_011960_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
Best Answer