%% Compute Expected Lower Partial Moments
% This example shows how to compute expected lower partial moments based on the mean and standard deviations of normally distributed asset returns. The elpm function works with the mean and standard deviations for multiple assets and multiple orders.

load FundMarketCash
Returns = tick2ret(TestData);
MAR = mean(Returns(:,3))
Mean = mean(Returns)
Sigma = std(Returns, 1)
Assets
ELPM = elpm(Mean, Sigma, MAR, [0 1 2])

% Based on the moments of each asset, the expected values for lower partial moments imply better than expected performance for the fund and market and worse than expected performance for cash. The elpm function works with either degenerate or nondegenerate normal random variables. For example, if cash were truly riskless, its standard deviation would be 0. You can examine the difference in average shortfall.

RisklessCash = elpm(Mean(3), 0, MAR, 1)

% Copyright 2020 The MathWorks, Inc.