Learn R Programming

poolABC (version 1.0.0)

weighted_stats: Compute weighted point estimates

Description

Computes the weighted mean, median and quantiles of a distribution.

Usage

weighted_stats(x, w, prob = c(0.05, 0.25, 0.75, 0.95))

Value

numeric vector with weighted mean, median and quantiles of size 2 + length(prob).

Arguments

x

numeric vector of size n with the observations.

w

numeric vector of size n with non-negative weights. Note that this vector needs to have the same length as the x vector.

prob

numeric vector of probabilities with values in [0,1].

Details

This function requires the MetricsWeighted::weighted_quantile() function and the weights to compute the weighted arithmetic mean and the weighted quantiles. By default, this function computes the 5%, 25%, 50% (corresponding to the median), 75% and 95% quantiles.