Suppose you are responsible for the management of a current company’s portfolio $P$ consisting of $N$ securities (e.g. equities) traded actively at NASDAQ. As a portfolio manager you probably are interested in portfolio performance, new asset allocation, and risk control. Therefore, your basic set of statistics should include **portfolio expected return**, $\mu_P$, and **portfolio standard deviation**, $\sigma_P$, as two key numbers you want to calculate every time you evaluate your portfolio performance.

**Coskewness**, $s_P$, and **cokurtosis**, $k_P$, are two additional *multivariate higher moments* (co-moments) important in asset allocation process and portfolio management. Similarly to the fundamental meaning of a sample’s skewness and kurtosis, the co-skewness and co-kurtosis provides a portfolio manager with an ability to test the same portfolio under different composition in order to facilitate changes required to be introduced (e.g. an elimination of some allocations in badly performing securities causing more pronounced negative coskewness).

In this post I will provide with the basic matrix algebra covering the computational solution for four portfolio statistics with a Matlab code example as a practical implementation of mathematics in action.

**Expected Return on Portfolio**

Let $P$ is our portfolio containing $N$ securities $K_i$ such that $P=\{K_1,K_2,…,K_N\}$ and $i=1,…,N$. Each security has a trading history for last T days (or months, or years) and we are looking for its $T-1$ rates of return $r_t$ for $t=1,…,T-1$. Therefore, let us denote by $K_i$ a column vector of dimensions $(T-1,1)$ such that:

$$

K_i = [r_1,r_2,…,r_{T-1}]^T\ ,

$$

and portfolio matrix, $P$, containing all securities as:

$$

P =

[K_1\ |\ K_2\ |\ …\ |\ K_N ]

=

\left[

\begin{array}{cccc}

r_{1,1} & r_{1,2} & … & r_{1,N} \\

r_{2,1} & r_{2,2} & … & r_{2,N} \\

… & … & … & … \\

r_{T-1,1} & r_{T-1,2} & … & r_{T-1,N}

\end{array}

\right] \ .

$$ Our portfolio can be described in term of their weights:

$$

w_i = \frac{y_iS_i(0)}{V(0)}

$$ where numerator describes the product of the number of shares and stock purchase price in ratio to the amount initially invested in the portfolio. Rewriting it into one-row matrix we have:

$$

w = [\ w_1\ \ w_2\ \ … \ \ w_N\ ]

$$ where from obvious reason the sum of individual weights is one or $1=uw^T$. For each security we can calculate its expected return $\mu_i=E(K_i)$ and form a vector:

$$

m = [\ \mu_1\ \ \mu_2\ \ … \ \ \mu_N\ ] \ .

$$

Finally, the **expected return on portfolio** $P$ is given as:

$$

\mu_P = mw^T \

$$ what follows:

$$

\mu_P = E(K_i) = E\left(\sum_{i=1}^{N} w_iK_i \right) = \sum_{i=1}^{N} w_i\mu_i = mw^T .

$$

**Portfolio Variance**

By evaluation of variance, we are able to show that the expected **portfolio variance** can be expressed as:

$$

\sigma_P = w M_2 w^T

$$

where $M_2$ is the *covariance matrix* $(N,N)$ with the individual covariances denoted by $c_{ij}=Cov(K_i,K_j)$. At this point, each element of $M_2$ could be calculated as $c_{ij}=\rho_{ij}\sigma_i\sigma_j$, i.e. with a knowledge of coefficient of correlation, $\rho_{ij}$, between the securities $i$ and $j$, and corresponding standard deviations calculated from the history provided by $P$ matrix.

Just as an educational remark, let me remind you that elements $c_{ij}$ can be obtained in the following way:

$$

c_{ij} = \frac{1}{[(T-1)-1)]} \sum_{i,j=1}^{N} \sum_{t=1}^{T-1} (K_{t,i}-\mu_i)(K_{t,j}-\mu_j) \ ,

$$ therefore

$$

M_2 =

\left[

\begin{array}{cccc}

c_{11} & c_{12} & … & c_{1N} \\

c_{21} & c_{22} & … & c_{2N} \\

… & … & … & … \\

c_{N1} & c_{N2} & … & c_{NN}

\end{array}

\right] .

$$

**Portfolio Coskewness**

It can calculated as a product of:

$$

s_P = w M_3 (w^T\otimes w^T)

$$

where the symbol of $\otimes$ denotes the Kronecker product between $w$ and $w$, and

$$

M_3 = E[(r-\mu)(r-\mu)^T\otimes(r-\mu)^T] = \{a_{ijk}\} \ , \\

a_{ijk} = E[(r_i-\mu_i)(r_j-\mu_j)(r_k-\mu_k)] \ \ \mbox{for}\ \ i,j,k=1,…,N.

$$

The *co-skewness matrix* of $M_3$ of dimensions $(N,N^2)$ can be represented by $N$ $A_{ijk}$ matrixes $(N,N)$ such that:

$$

M_3 = [\ A_{1jk}\ A_{1jk}\ …\ A_{Njk}\ ]

$$

where $j,k=1,…,N$ as well as for an index $i$. The individual elements of the matrix can be obtained as:

$$

a_{ijk} = \frac{1}{T-1} \sum_{i,j,k=1}^{N} \sum_{t=1}^{T-1} (K_{t,i}-\mu_i)(K_{t,j}-\mu_j)(K_{t,k}-\mu_k) \ .

$$

**Portfolio Cokurtosis**

Cokurtosis can be obtained by calculation of the following products:

$$

k_P = w M_4 (w^T\otimes w^T\otimes w^T)

$$ where

$$

M_4 = E[(r-\mu)(r-\mu)^T\otimes(r-\mu)^T\otimes(r-\mu)^T] = \{b_{ijkl}\} \ , \\

b_{ijkl} = E[(r_i-\mu_i)(r_j-\mu_j)(r_k-\mu_k)(r_l-\mu_l)] \ \ \mbox{for}\ \ i,j,k,l=1,…,N.

$$

The *co-kurtosis matrix* $M_4$ of dimensions $(N,N^3)$ can be represented by $N$ $B_{ijkl}$ matrixes $(N,N)$ such that:

$$

M_4 = [\ B_{11kl}\ B_{12kl}\ …\ B_{1Nkl}\ |\ B_{21kl}\ B_{22kl}\ …\ B_{2Nkl}\ |\ …\ |\ B_{N1kl}\ B_{N2kl}\ …\ B_{NNkl}\ ]

$$

where $k,l=1,…,N$. The individual elements of the matrix can be obtained as:

$$

b_{ijkl} = \frac{1}{T-1} \sum_{i,j,k,l=1}^{N} \sum_{t=1}^{T-1} (K_{t,i}-\mu_i)(K_{t,j}-\mu_j)(K_{t,k}-\mu_k)(K_{t,l}-\mu_l) \ .

$$

**Example**

Below I present a simple Matlab code which computes discussed above portfolio key four portfolio statistics based on $N=3$ securities traded within given $P$. The choice of portfolio content is not solely limited to equities, and $P$ can contain any asset class under management, or even their mixture. Since the expected portfolio return and risk, $\mu_P$ and $\sigma_P$, respectively, are assumed to be expressed as percent, their transformation to a physical unit of money can be straightforwardly obtained.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | % Program demonstrates the calculattion of portfolio four key statistics: % the expected portfolio return (muP), portfolio standard deviation (sigP), % portfolio co-skewness (sP), and portfolio co-kurtosis (kP). % % (c) 2013, QuantAtRisk.com, by Pawel Lachowicz % % Assumptions: * portfolio comprises 252 trading days, i.e. T=252-1 values % of daily returns % * daily returns are simulated from the normal distribution % with zero mean and unit standard deviation (in practice % one can use real market data) % * N=3, number of securities in portfolio P % % Remark: the code can be easily modified for the need of any N securities % considered in your portfolio P; it is not difficult to note that % the calcution of all four statistics can be performed by risk % managers who manage the porfolio P of portfolios P_i such that % P=[P_1 P_2 ... P_N] clear all; clc; close all; T=252; % Simulated returns for 3 securities X,Y,Z expressed in [%] X=random('normal',0,1,T-1,1); Y=random('normal',0,1,T-1,1); Z=random('normal',0,1,T-1,1); % Portfolio matrix P=[X Y Z]; % Portfolio weights for all securities (sum=1) w=[0.2 0.5 0.3]; % m-vector containing the expected returns of securities m=mean([P(:,1) P(:,2) P(:,3)]); % Computation of M2, the covariance matrix S=[]; for i=1:size(P,2) for j=1:size(P,2) u=0; for t=1:T-1 u=u+((P(t,i)-mean(P(:,i)))*(P(t,j)-mean(P(:,j)))); end S(i,j)=u/((T-1)-1); end end M2=S; % % Computation of M3, the co-skewness matrix M3=[]; for i=1:size(P,2) S=[]; for j=1:size(P,2) for k=1:size(P,2) u=0; for t=1:T-1 u=u+((P(t,i)-mean(P(:,i)))*(P(t,j)-mean(P(:,j))) ... *(P(t,k)-mean(P(:,k)))); end S(j,k)=u/(T-1); end end M3=[M3 S]; end % Computation of M4, the co-kurtosis matrix M4=[]; for i=1:size(P,2) for j=1:size(P,2) S=[]; for k=1:size(P,2) for l=1:size(P,2) u=0; for t=1:T-1 u=u+((P(t,i)-mean(P(:,i)))*(P(t,j)-mean(P(:,j)))* ... (P(t,k)-mean(P(:,k)))*(P(t,l)-mean(P(:,l)))); end S(k,l)=u/(T-1); end end M4=[M4 S]; end end % Results muP=m*w' % expected return on a portfolio [%] stdP=sqrt(w*M2*w') % portfolio standard deviation [%] sK=w*M3*kron(w',w') % portfolio coskewness sP=w*M4*kron(kron(w',w'),w') % portfolio cokurtosis |