spCdfplot: Plot weighted cumulative distribution functions

View source: R/spCdfplot.R

spCdfplotR Documentation

Plot weighted cumulative distribution functions

Description

Plot cumulative distribution functions, possibly broken down according to conditioning variables and taking into account sample weights.

Usage

spCdfplot(
  inp,
  x,
  cond = NULL,
  approx = c(FALSE, TRUE),
  n = 10000,
  bounds = TRUE,
  ...
)

panelSpCdfplot(x, y, approx, bounds = TRUE, ...)

prepanelSpCdfplot(x, y, ...)

getCdf(x, weights = NULL, cond = NULL, data, ..., name = "")

prepCdf(x, w, ..., name = "")

## S3 method for class 'data.frame'
prepCdf(x, w, ..., name = "")

## Default S3 method:
prepCdf(x, w, ..., name = "")

Arguments

inp

an object of class simPopObj 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.

approx

logicals indicating whether approximations of the cumulative distribution functions should be computed. The default is to use FALSE for the survey data and TRUE for the population data.

n

integers specifying the number of points at which the approximations take place (see approx). It is used wherever approx is TRUE.

bounds

a logical indicating whether vertical lines should be drawn at 0 and 1 (the bounds for cumulative distribution functions).

...

further arguments to be passed to xyplot.

Details

Weights are directly extracted from the input object inp and are taken into account by adjusting the step height. To be precise, the weighted step height for an observation is defined as its weight divided by the sum of all weights\ ( w_{i} / \sum_{j = 1}^{n} w_{j} ).

Value

An object of class "trellis", as returned by xyplot.

Author(s)

Andreas Alfons

References

A. Alfons, M. Templ (2011) Simulation of close-to-reality population data for household surveys with application to EU-SILC. Statistical Methods & Applications, 20 (3), 383–407. doi: 10.1007/s10260-011-0163-2

See Also

spCdf, xyplot

Examples

## 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
## Not run: 
## approx. 20 seconds computation time
inp <- specifyInput(data=eusilcS, hhid="db030", hhsize="hsize",
  strata="db040", weight="db090")
simPop <- simStructure(data=inp, method="direct",
  basicHHvars=c("age", "rb090", "hsize", "pl030", "pb220a"))

# multinomial model with random draws
eusilcM <- simContinuous(simPop, additional="netIncome",
  regModel = ~rb090+hsize+pl030+pb220a,
  upper=200000, equidist=FALSE, nr_cpus=1)
class(eusilcM)

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

## End(Not run)

statistikat/simPop documentation built on March 24, 2024, 5:05 a.m.