R/RcppExports.R

Defines functions tau_scale m_scale my_median constC2 constC1 normal_consistency_constants derpsiOpt derpsiAux psiOpt psiAux rhoOpt rhoAux distance_to_centers

Documented in m_scale normal_consistency_constants psiAux psiOpt rhoAux rhoOpt

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

distance_to_centers <- function(data, centers) {
    .Call('_ktaucenterscpp_distance_to_centers', PACKAGE = 'ktaucenterscpp', data, centers)
}

#' rhoAux function
#'
#' Auxiliary function to compute rho and psi
rhoAux <- function(x, cc) {
    .Call('_ktaucenterscpp_rhoAux', PACKAGE = 'ktaucenterscpp', x, cc)
}

#'rhoOpt function
#'
#' An implementation of quasi optimal rho functions following reference [1]
#'
#'@param x real number.
#'@param cc tunning constant.
#'@return rho(\code{x}/\code{c}\code{c})
#'@examples val = rhoOpt(x = 0.5, cc = 1)
#'@references [1] Salibian-Barrera, M., Willems, G., & Zamar,
#'   R. (2008). The fast-tau estimator for regression. Journal of
#'   Computational and Graphical Statistics, 17(3), 659-682.
#'
#'@export
rhoOpt <- function(x, cc) {
    .Call('_ktaucenterscpp_rhoOpt', PACKAGE = 'ktaucenterscpp', x, cc)
}

#'psiAux function
#'
#' An implementation of quasi optimal rho functions following reference [1]
#'
#'@param x real number.
#'@param cc tunning constant.
#'@return rho(\code{x}/\code{c}\code{c})
#'@examples val = rhoOpt(x = 0.5, cc = 1)
#'@references [1] Salibian-Barrera, M., Willems, G., & Zamar,
#'   R. (2008). The fast-tau estimator for regression. Journal of
#'   Computational and Graphical Statistics, 17(3), 659-682.
#'
#'@export
psiAux <- function(x, cc) {
    .Call('_ktaucenterscpp_psiAux', PACKAGE = 'ktaucenterscpp', x, cc)
}

#' psiOpt
#' psi function is the derivative of optimal rho function (see \code{\link{rhoOpt}})
#' @param x A real number.
#' @param cc a tunning constant.
#' @return rho''(\code{x}/ \code{c}\code{c})
#' @examples
#' psiOpt(x=0.5,cc=1)
#' @export
psiOpt <- function(x, cc) {
    .Call('_ktaucenterscpp_psiOpt', PACKAGE = 'ktaucenterscpp', x, cc)
}

derpsiAux <- function(x, cc) {
    .Call('_ktaucenterscpp_derpsiAux', PACKAGE = 'ktaucenterscpp', x, cc)
}

derpsiOpt <- function(x, cc) {
    .Call('_ktaucenterscpp_derpsiOpt', PACKAGE = 'ktaucenterscpp', x, cc)
}

#'  normal_consistency_constants
#'
#' @description constants previously computed in order to the M scale
#'   value be consistent with the standard normal distribution for
#'   the optimal rho function considered in \code{\link{rhoOpt}}.
#'   (Constant were computed from p=1 till p =400)
#'
#' @param p dimension where observation lives
#' @return cvalue
#'
#' @examples
#' p=5;
#' n=1000
#' X=matrix(rnorm(n*p), ncol=p)
#' dist=apply(X,1,function(t){sqrt(sum(t^2))})
#' s= Mscale(dist,b=0.5, c=normal_consistency_constants(p))
#'
#' ### variable s should be near from one for all p values between 1 and 400.
#'
#' @references [1] Maronna, R. A., Martin, R. D., Yohai, V. J., &
#'   Salibián-Barrera, M. (2018).
#' Robust statistics: theory and methods (with R). Wiley.
#' [2] Salibian-Barrera, M., Willems, G., & Zamar, R. (2008).
#' The fast-tau estimator for regression.
#' Journal of Computational and Graphical Statistics, 17(3), 659-682.
#'
#' @export
normal_consistency_constants <- function(p) {
    .Call('_ktaucenterscpp_normal_consistency_constants', PACKAGE = 'ktaucenterscpp', p)
}

constC1 <- function(p) {
    .Call('_ktaucenterscpp_constC1', PACKAGE = 'ktaucenterscpp', p)
}

constC2 <- function(p) {
    .Call('_ktaucenterscpp_constC2', PACKAGE = 'ktaucenterscpp', p)
}

my_median <- function(x) {
    .Call('_ktaucenterscpp_my_median', PACKAGE = 'ktaucenterscpp', x)
}

#' Mscale
#' the M scale of an univariate sample (see reference below)
#'
#' @param u an univariate sample of size n.
#' @param b the desired break down point
#' @param cc a tuning constant, if consistency to standard normal
#'   distribution is desired use
#' \code{\link{normal_consistency_constants}}
#' @return the Mscale value
#' @examples
#' Mscale(u=rnorm(100),c=1)
#'
#' @importFrom stats median
#' @references Maronna, R. A., Martin, R. D., Yohai, V. J., & Salibian-Barrera, M. (2018).
#' Robust statistics: theory and methods (with R). Wiley.
#' @export
m_scale <- function(u, b, cc) {
    .Call('_ktaucenterscpp_m_scale', PACKAGE = 'ktaucenterscpp', u, b, cc)
}

tau_scale <- function(u, b1, b2, c1, c2) {
    .Call('_ktaucenterscpp_tau_scale', PACKAGE = 'ktaucenterscpp', u, b1, b2, c1, c2)
}
anevolbap/ktaucenterscpp documentation built on March 10, 2021, 10:12 a.m.