# Weighted descriptive statistics

This package contains functions for weighted descriptive statistics.
The three functions provided are:

## wfreq(series x, series w, bool verbose[0])

* x: series to calculate frequencies for (must be discrete)
* w: weights series
* verbose: optional boolean flag for displaying results (default: no)

Output: a 3-column matrix holding the values of x and the plain and
weighted frequencies, respectively. Note that displayed
results are rounded to the nearest integer.

## wquantile(series x, matrix q, series w)

* x: series to calculate the desired quantile for
* q: quantiles (between 0 and 1)
* w: weights series

Output: a row vector with the quantiles contained in q. Note that when
q=0.5 and x is continuous the result may be slightly different
from the median reported by the "summary" command with the
--weights option because of a different calculation algorithm. The
difference (if any) should be small for large samples
anyway. **Note**: in previous versions, this function used a scalar
for the second argument and consequently would return a scalar. At
present, when `q` is a scalar argument the returned value is a 1x1
matrix, so be sure to recast it as a scalar if needed.

## wxtab(series x, series y, series w, bool verbose[0])

* x, y: series to calculate the contingency table for (both must be discrete)
* w: weights series verbose: optional boolean flag for displaying results (default: no)

Output: the weighted contingency table. Note that displayed
results are rounded to the nearest integer.

# CHANGELOG:

1.0: Initial release

1.1: Added weighted quantiles; fixed a bug in `wxtab`; added support for
     string-valued variables
	 
1.2: No substantive user-visible changes: just an internal fix to
     accommodate a syntax change in hansl in 2023b and a little
     prettification to the plot in the sample script. 
	 
1.3: Generalise syntax of `wquantile` by allowing vector 2nd argument;
     added value labels for printout of `wfreq`. Change help format to
     markdown.
