Learn R Programming

simPop (version 0.2.6)

spBwplot: Weighted box plots

Description

Produce box-and-whisker plots of continuous or semi-continuous variables, possibly broken down according to conditioning variables and taking into account sample weights.

Usage

spBwplot(inp, x, cond = NULL, horizontal = TRUE, coef = 1.5, zeros = TRUE,
  minRatio = NULL, do.out = FALSE, ...)

Arguments

inp
an object of class synthPopObj containing survey sample and synthetic population data.
x
a character vector specifying the columns of data available in the sample and the population (specified in input object 'inp') to be plotted.
cond
an optional character vector (of length 1, if used) specifying the conditioning variable.
horizontal
a logical indicating whether the boxes should be horizontal or vertical.
coef
a numeric value that determines the extension of the whiskers.
zeros
a logical indicating whether the variables specified by x are semi-continuous, i.e., contain a considerable amount of zeros. If TRUE, the box widths correspond to the proportion of non-zero data points and the (weighted) box plot
minRatio
a numeric value in $(0,1]$; if zeros is TRUE, the boxes may become unreadable for a large proportion of zeros. In such a case, this can be used to specify a minimum ratio for the box widths. Variable box widths for semi-continuou
do.out
a logical indicating whether data points that lie beyond the extremes of the whiskers should be plotted. Note that this is FALSE by default.
...
further arguments to be passed to bwplot.

Value

  • An object of class "trellis", as returned by bwplot.

Details

Missing values are ignored for producing box plots and weights are directly extracted from the input object inp.

See Also

spBwplotStats, bwplot

Examples

Run this code
## these take some time and are not run automatically
## copy & paste to the R command line

set.seed(1234)  # for reproducibility
data(eusilcS)   # load sample data
inp <- specifyInput(data=eusilcS, hhid="db030", hhsize="hsize", 
  strata="db040", weight="db090")
synthPop <- simStructure(data=inp, method="direct",
  basicHHvars=c("age", "rb090", "hsize", "pl030", "pb220a"))

# multinomial model with random draws
eusilcM <- simContinuous(synthPop, additional="netIncome", 
  upper=200000, equidist=FALSE)
class(eusilcM)

# plot results
spBwplot(eusilcM, x="netIncome", cond=NULL)
spBwplot(eusilcM, x="netIncome", cond="rb090", layout=c(1,2))

Run the code above in your browser using DataLab