R/trunc_fun.R

Defines functions trunc_fun

Documented in trunc_fun

#' Trimming
#'
#' The function trims the weights for IPTW methods.
#'
#' @param x A numeric vector
#' @param trim_perc A numeric vector with length 2 indicating trimming
#' percentile.
#'
#' @return A numeric vector
#'
trunc_fun <- function(x, trim_perc = 0.05) {
    pmin(stats::quantile(x, trim_perc[2]),
         pmax(stats::quantile(x, trim_perc[1]), x))
}

Try the CIMTx package in your browser

Any scripts or data that you put into this service are public.

CIMTx documentation built on June 24, 2022, 9:07 a.m.