weighted_moment | R Documentation |
The weighted_moment is a wrapper around R's weighted_mean which raises the variable x to the power a before taking the weighted mean. weighted_var and weighted_std are based on weighted_moment.
weighted_moment(x, w, a = 1, ranked = x, na.rm = FALSE)
x |
the variable whose moment is to be estimated |
w |
the weights |
a |
the degree of the moment |
na.rm |
a logical indicating whether NA's should removed |
probs |
the probabilities of the quantiles |
names |
no idea what this does |
The weighted_quantile function yields a version of quantiles which does not quite reach the sophistication of that built into R. In particular, for a probability p this function yields the highest x for which cumsum(w)/sum(w) < p, rather than some interpolated value. weighted_median is weighted_quantile(x,w, p = .5)
The desired statistic. Weighted quantile produces a vector with length(probs).
Markus Jantti markus.jantti@iki.fi
weighted_mean
, cov.wt
x <- rexp(100)
w <- rpois(100,5)
weighted_median(x, w)
weighted_moment(x,w, 1)
weighted_mean(x,w, 1)
weighted_var(x,w)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.