Library: | plot |
See also: | plothist plotbox plotdot |
Quantlet: | plothistwtd | |
Description: | Plots a weighted histogram of x |
Usage: | plothistwtd(inX, inWeights {,inTicks}) | |
Input: | ||
inX | n x 1 Vector of continuous data. | |
inWeights | n x 1 Vector of weights. | |
inTicks | m x 1 Vector. Specifying the (m-1) intervalls for the histogram. |
inTicks[i] < inTicks[i+1] must hold for all i=1, ..., m-1.
The weights provided are automatically rescaled to sum up to one. If the sum of weights is sufficiently close to zero, the weights are applied "as is".
library("plot") Mean = #(1, 1.1, 1.6, 1.2, 2.5, 2.2, 2.9, 3.2, 4.1) Fraction = #(0.5, 0.7, 3, 1.1, 1.2, 4.0, 1.3, 2.8, 0.9) plothist(Mean, 1:5) plothistwtd(Mean, Fraction, 1:5)
You see two histograms - one standard histogram and one weighted histogram. In this example means for different subgroups of a dataset have been computed. In the standard histogram all means have the same weight, disregarding the size of the underlying sample. In the weighted histogram the sample size (here as fraction of the whole dataset) is provided. Note the different shape (and hence interpretation!) of the two histograms.