Problem 3074. Compute the cokurtosis of a given portfolio.
As input data, you are given a nObs-by-nAssets matrix portRet of return series for assets in a portfolio along with an nAssets-by-1 vector portWeights of portfolio weights. Example:
>> nObs = 504; % Number of observations
>> nAssets = 5; % Number of assets in the portfolio
>> portRet = randn(nObs, nAssets); % Sample portfolio return series
>> portWeights = rand(nAssets, 1);
>> portWeights = portWeights/sum(portWeights); % Portfolio weights are >=0 and sum to 1.
The task is to compute the portfolio cokurtosis , which is a scalar statistic associated with the portfolio. A full description of this statistic, along with sample MATLAB code for computing it, can be found here:
http://www.quantatrisk.com/2013/01/20/coskewness-and-cokurtosis/
Write a function that accepts portRet and portWeights as input arguments and returns the scalar statistic portCokurt as its output. You can use the code at the website above as a starting point, but try to simplify and shorten it in the spirit of Cody.
Solution Stats
Problem Comments
-
2 Comments
The author intenionally hide some info about the website's matlab code, since both of fomula and code calculate M4 with slightly different way, in Cody, you DO NOT NEED to minus the mean of P, unlike this website's code actually did that. I learned that in hard way, but deeply hope you guys enjoy to optimize this code.
A major part of the article including the code is not accessible to non-members of the website.
Solution Comments
Show commentsProblem Recent Solvers5
Suggested Problems
-
16987 Solvers
-
2291 Solvers
-
Calculate the Levenshtein distance between two strings
1422 Solvers
-
1238 Solvers
-
Magic is simple (for beginners)
9088 Solvers
More from this Author4
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!