cgroll / ModernPortfolioTheory

This is the common repository for the LMU course "Modern Portfolio Theory with Matlab"
1 stars 6 forks source link

gini coefficient with shortselling #27

Closed cgroll closed 10 years ago

cgroll commented 10 years ago

the gini coefficient formula needs to be updated, since our portfolio weights could become negative, while the gini coefficient is based on relative frequencies that are always positive (as you already mentioned yourself). One possible adjustment could be to take absolute values of each weight and rescale this new vector of now positive weights again to sum up to one.

thomasMff commented 10 years ago

updated (and corrected for tables)

cgroll commented 10 years ago

you probably did forget to publish your modifications, but in my version the gini coefficient is still wrong. if you fix it, however, feel free to close this issue yourself.

thomasMff commented 10 years ago

Everywhere I looked it showed the following update, however not distinctively marked as such:

% gini coefficient for negative weights absweights = abs(weights); absweights = absweights./repmat(sum(absweights,2),1,size(weights,2)); gini = sum(absweights.^2);

That is supposed to be what you have described as a possible solution. Is this correct?

cgroll commented 10 years ago

the code you show here looks correct. nevertheless, in the current commit e2f7b501745ce897bb8ffb1b9d0ed19e843b060d (message: function script folder) on the develop branch, the code of function diversification in folder performance still is:

% calculate measures
numberAssets = sum(weights~=0, 2);
numberSignificantAssets = sum(abs(weights-0)>0.0001,2);
maxWeight = max(abs(weights)')'; % maximum absolute value of weights
stdWeights = std(weights,0,2); % second argument is default normalization
% (by N-1 instead of N)
numberShort = sum(weights<0,2);
gini = sum(weights.^2,2);
% Herfindahl index as special case of gini coefficient because of the 
% limited number of assets (but does not distinguish between sign (positive
% or negative values)

did you put it somewhere else?

thomasMff commented 10 years ago

I have also discoverd the problem you are talking about. I had 2 diversification.m opened in my matlab and one of them was the old one. I could not save the new one, so I will copy the content from the new one into the file of the old one and hope for the best. I think it's strange, however, that I could find the new one in the commits correctly.

cgroll commented 10 years ago

fixed by f23172f8c39207b2b3c50a97779a29fd468c4f06