Calculate the realized semivariances, defined in Barndorff-Nielsen et al. (2008).
Function returns two outcomes:
Downside realized semivariance
Upside realized semivariance.
Assume there are \(N\) equispaced returns \(r_{t,i}\) in period \(t\), \(i=1, \ldots,N\).
Then, the rSVar
is given by
$$
\mbox{rSVardownside}_{t}= \sum_{i=1}^{N} (r_{t,i})^2 \ \times \ I [ r_{t,i} < 0]
$$
$$
\mbox{rSVarupside}_{t}= \sum_{i=1}^{N} (r_{t,i})^2 \ \times \ I [ r_{t,i} > 0]
$$