DownsideDeviation(Ra, MAR = 0, method=c("subset","full"))
SemiDeviation(Ra)
SemiVariance(Ra)
To calculate it, we take the subset of returns that are less than the target (or Minimum Acceptable Returns (MAR)) returns and take the differences of those to the target. We sum the squares and divide by the total number of returns to get a below-target semi-variance.
$$DownsideDeviation(R , MAR)= \delta_{MAR} = \sqrt{ \frac{\sum^{n}_{t=1}(R_{t} - MAR)^{2}}{n} }$$
where $n$ is either the number of observations of the entire series or the number of observations in the subset of the series falling below the MAR.
SemiDeviation or SemiVariance is a popular alternative downside risk measure that may be used in place of standard deviation or variance. SemiDeviation and SemiVariance are implemented as a wrapper of DownsideDeviation with MAR=mean(R).
In many functions like Markowitz optimization, semideviation may be substituted directly, and the covariance matrix may be constructed from semideviation or the vector of returns below the mean rather than from variance or the full vector of returns.
In semideviation, by convention, the value of $n$ is set to the full number of observations. In semivariance the the value of $n$ is set to the subset of returns below the mean. It should be noted that while this is the correct mathematical definition of semivariance, this result doesn't make any sense if you are also going to be using the time series of returns below the mean or below a MAR to construct a semi-covariance matrix for portfolio optimization.
Sortino recommends calculating downside deviation utilizing a continuous fitted distribution rather than the discrete distribution of observations. This would have significant utility, especially in cases of a small number of observations. He recommends using a lognormal distribution, or a fitted distribution based on a relevant style index, to construct the returns below the MAR to increase the confidence in the final result. Hopefully, in the future, we'll add a fitted option to this function, and would be happy to accept a contribution of this nature.
data(edhec)
head(edhec[,6,drop=FALSE])
sd(edhec[,6])
DownsideDeviation(edhec[,6]) # MAR 0\%
DownsideDeviation(edhec[,6], MAR = .04/12) #MAR 4\%
DownsideDeviation(edhec[,6], MAR = mean(edhec[,6])) #MAR = mean return, calculate semivariance
SemiDeviation(edhec[,7])
SemiVariance (edhec[,7]) #calculated using method="subset"
Run the code above in your browser using DataLab