R/RcppExports.R

Defines functions RcOut resid mat fgyfl k1 k2 k3 k4 k5 k6 st_cumulants minfunc k4m k4m_1st k4m_2nd

Documented in k1 k2 k3 k4 k5 k6

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

RcOut <- function(A, B, C, D, PD, LGD, weight, EAD, CORR, UL) {
    .Call('_ECTools_RcOut', PACKAGE = 'ECTools', A, B, C, D, PD, LGD, weight, EAD, CORR, UL)
}

resid <- function(A, B, C, D, PD, LGD, weight, EAD, CORR, UL, RcIn) {
    .Call('_ECTools_resid', PACKAGE = 'ECTools', A, B, C, D, PD, LGD, weight, EAD, CORR, UL, RcIn)
}

mat <- function(FG, FL, RU, col) {
    .Call('_ECTools_mat', PACKAGE = 'ECTools', FG, FL, RU, col)
}

fgyfl <- function(x, lim, n) {
    .Call('_ECTools_fgyfl', PACKAGE = 'ECTools', x, lim, n)
}

#' The first raw moment
#'
#' @param loss vector with input
#' @param scale scale parameter
#'
#' @return The first raw moment is the mean
#'
#' @references https://en.wikipedia.org/wiki/Moment_(mathematics)
#'
#' @export
#'
k1 <- function(x) {
    .Call('_ECTools_k1', PACKAGE = 'ECTools', x)
}

#' The second central moment
#'
#' @param loss vector with input
#' @param scale scale parameter
#'
#' @return The second central moment is the variance. Its positive square root is the standard deviation σ.
#'
#' @references https://en.wikipedia.org/wiki/Moment_(mathematics)
#'
#' @export
#'
k2 <- function(x) {
    .Call('_ECTools_k2', PACKAGE = 'ECTools', x)
}

#' The third central moment
#'
#' @param loss vector with input
#' @param scale scale parameter
#'
#' @return The third central moment is the measure of the lopsidedness of the distribution; any symmetric distribution will have a third
#' central moment, if defined, of zero. The normalised third central moment is called the skewness, often Gamma. A distribution that is
#' skewed to the left (the tail of the distribution is longer on the left) will have a negative skewness. A distribution that is skewed
#' to the right (the tail of the distribution is longer on the right), will have a positive skewness.
#' For distributions that are not too different from the normal distribution, the median will be somewhere near MU − Gamma * Sigma / 6;
#' the mode about MU − Gamma * Sigma / 2.
#'
#' @references https://en.wikipedia.org/wiki/Moment_(mathematics)
#'
#' @export
#'
k3 <- function(x) {
    .Call('_ECTools_k3', PACKAGE = 'ECTools', x)
}

#' The fourth central moment
#'
#' @param loss vector with input
#' @param scale scale parameter
#'
#' @return The fourth central moment is a measure of the heaviness of the tail of the distribution, compared to the normal distribution
#' of the same variance. Since it is the expectation of a fourth power, the fourth central moment, where defined, is always positive;
#' and except for a point distribution, it is always strictly positive. The fourth central moment of a normal distribution is 3 * Sigma 4.
#'
#' The kurtosis K is defined to be the normalised fourth central moment minus 3 (Equivalently, as in the next section, it is the fourth
#' cumulant divided by the square of the variance). Some authorities do not subtract three, but it is usually more convenient to have the
#' normal distribution at the origin of coordinates.[4][5] If a distribution has heavy tails, the kurtosis will be high (sometimes called
#' leptokurtic); conversely, light-tailed distributions (for example, bounded distributions such as the uniform) have low kurtosis (sometimes
#' called platykurtic).
#'
#' The kurtosis can be positive without limit, but K must be greater than or equal to Gamma * 2 − 2; equality only holds for binary distributions.
#' For unbounded skew distributions not too far from normal, K tends to be somewhere in the area of Gamma * 2 and 2 * Gamma * 2.
#'
#' The inequality can be proven by considering
#'
#' E[(T^2-aT-1)^2
#'
#' where T = (X − μ)/σ. This is the expectation of a square, so it is non-negative for all a; however it is also a quadratic polynomial in a.
#' Its discriminant must be non-positive, which gives the required relationship.
#'
#' @references https://en.wikipedia.org/wiki/Moment_(mathematics)
#'
#' @export
#'
k4 <- function(x) {
    .Call('_ECTools_k4', PACKAGE = 'ECTools', x)
}

#' The fifth central moment
#'
#' @param loss vector with input
#' @param scale scale parameter
#'
#' @return High-order moments are moments beyond 4th-order moments. As with variance, skewness, and kurtosis, these are higher-order statistics,
#' involving non-linear combinations of the data, and can be used for description or estimation of further shape parameters. The higher the moment,
#' the harder it is to estimate, in the sense that larger samples are required in order to obtain estimates of similar quality. This is due to the
#' excess degrees of freedom consumed by the higher orders. Further, they can be subtle to interpret, often being most easily understood in terms of
#' lower order moments – compare the higher derivatives of jerk and jounce in physics. For example, just as the 4th-order moment (kurtosis) can be
#' interpreted as "relative importance of tails versus shoulders in causing dispersion" (for a given dispersion, high kurtosis corresponds to heavy
#' tails, while low kurtosis corresponds to broad shoulders), the 5th-order moment can be interpreted as measuring "relative importance of tails
#' versus center (mode, shoulders) in causing skew" (for a given skew, high 5th moment corresponds to heavy tail and little movement of mode, while
#' low 5th moment corresponds to more change in shoulders).
#'
#' @references https://en.wikipedia.org/wiki/Moment_(mathematics)
#'
#' @export
#'
k5 <- function(x) {
    .Call('_ECTools_k5', PACKAGE = 'ECTools', x)
}

#' The sixth central moment
#'
#' @param loss vector with input
#' @param scale scale parameter
#'
#' @return High-order moments are moments beyond 4th-order moments. As with variance, skewness, and kurtosis, these are higher-order statistics,
#' involving non-linear combinations of the data, and can be used for description or estimation of further shape parameters. The higher the moment,
#' the harder it is to estimate, in the sense that larger samples are required in order to obtain estimates of similar quality. This is due to the
#' excess degrees of freedom consumed by the higher orders. Further, they can be subtle to interpret, often being most easily understood in terms
#' of lower order moments – compare the higher derivatives of jerk and jounce in physics. For example, just as the 4th-order moment (kurtosis) can
#' be interpreted as "relative importance of tails versus shoulders in causing dispersion" (for a given dispersion, high kurtosis corresponds to
#' heavy tails, while low kurtosis corresponds to broad shoulders), the 5th-order moment can be interpreted as measuring "relative importance of
#' tails versus center (mode, shoulders) in causing skew" (for a given skew, high 5th moment corresponds to heavy tail and little movement of mode,
#' while low 5th moment corresponds to more change in shoulders).
#'
#' @references https://en.wikipedia.org/wiki/Moment_(mathematics)
#'
#' @export
#'
k6 <- function(x) {
    .Call('_ECTools_k6', PACKAGE = 'ECTools', x)
}

#' @export
st_cumulants <- function(location, escala, shape, df) {
    .Call('_ECTools_st_cumulants', PACKAGE = 'ECTools', location, escala, shape, df)
}

minfunc <- function(par, x, n_days) {
    .Call('_ECTools_minfunc', PACKAGE = 'ECTools', par, x, n_days)
}

k4m <- function(k, s) {
    .Call('_ECTools_k4m', PACKAGE = 'ECTools', k, s)
}

k4m_1st <- function(k, s) {
    .Call('_ECTools_k4m_1st', PACKAGE = 'ECTools', k, s)
}

k4m_2nd <- function(k, s) {
    .Call('_ECTools_k4m_2nd', PACKAGE = 'ECTools', k, s)
}
dangulod/ECTools documentation built on May 4, 2019, 3:19 p.m.