Weighted box plot statistics

Share:

Description

Compute the statistics necessary for producing box-and-whisker plots of continuous or semi-continuous variables, taking into account sample weights.

Usage

1
2
spBwplotStats(x, weights = NULL, coef = 1.5, zeros = TRUE,
  do.out = TRUE)

Arguments

x

a numeric vector.

weights

an optional numeric vector containing sample weights.

coef

a numeric value that determines the extension of the whiskers.

zeros

a logical indicating whether the variable specified by additional is semi-continuous, i.e., contains a considerable amount of zeros. If TRUE, the (weighted) box plot statistics are computed for the non-zero data points only and the number of zeros is returned, too.

do.out

a logical indicating whether data points that lie beyond the extremes of the whiskers should be returned.

Details

The function quantileWt is used for the computation of (weighted) quantiles. The median is computed together with the first and the third quartile, which form the box. If range is positive, the whiskers extend to the most extreme data points that have a distance to the box of no more than coef times the interquartile range. For coef = 0, the whiskers mark the minimum and the maximum of the sample, whereas a negative value causes an error.

Value

A list of class "spBwplotStats" with the following components:

stats

A vector of length 5 containing the (weighted) statistics for the construction of a box plot.

n

if weights is NULL, the number of non-missing and, if zeros is TRUE, non-zero data points. Otherwise the sum of the weights of the corresponding points.

nzero

if zeros is TRUE and weights is NULL, the number of zeros. If zeros is TRUE and weights is not NULL, the sum of the weights of the zeros. If zeros is not TRUE, this is NULL.

out

if do.out, the values of any data points that lie beyond the extremes of the whiskers.

Author(s)

Stefan Kraft and Andreas Alfons

See Also

spBwplot, for producing (weighted) box plots of continuous or semi-continuous variables.

quantileWt for the computation of (weighted) sample quantiles.

boxplot.stats for the unweighted statistics for box plots (not considering semi-continuous variables).

Examples

1
2
3
4
5
data(eusilcS)

## semi-continuous variable
spBwplotStats(eusilcS$netIncome, 
    weights=eusilcS$rb050, do.out = FALSE)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.