R/miceadds_weighted_centering.R

Defines functions miceadds_weighted_centering

## File Name: miceadds_weighted_centering.R
## File Version: 0.06

miceadds_weighted_centering <- function(x, w)
{
    require_namespace(pkg="sirt")
    if (is.matrix(x)){
        n <- nrow(x)
        cx <- colSums(x*w) / sum(w)
        xs <- x - sirt::sirt_matrix2(cx, nrow=n)
    } else {
        xs <- x - stats::weighted.mean(x, w=w)
    }
    return(xs)
}

Try the miceadds package in your browser

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

miceadds documentation built on Jan. 7, 2023, 1:09 a.m.