calc_skew | R Documentation |
Calculate the skewness or kurtosis of a time series of returns.
calc_skew(retp, expn = 3)
retp |
A time series of returns, with multiple columns. |
expn |
The power (exponent) to raise the returns (the default is
|
The function calc_skew()
calculates the skewness or kurtosis
of a time series of returns.
The function calc_skew()
performs an sapply() loop over the columns
of the retp
argument. It raise the returns to the power expn
.
If expn = 3
it calculates the skewness.
If expn = 4
it calculates the kurtosis.
The skewness \varsigma
is defined as:
\varsigma = \frac{1}{n-1} \sum_{i=1}^n {(\frac{r - \bar{r}}{\sigma})^3}
Where r
are the daily returns, \bar{r}
are the average returns,
and \sigma
is their standard deviation.
The kurtosis \kappa
is defined as:
\kappa = \frac{1}{n-1} \sum_{i=1}^n {(\frac{r - \bar{r}}{\sigma})^4}
A matrix of the skewness or kurtosis values.
# Calculate the kurtosis of VTI and IEF returns
rutils::calc_skew(rutils::etfenv$returns[, c("VTI", "IEF")], expn=4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.