Learn R Programming

simPop (version 2.1.3)

spCdfplot: 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 data.frame prepCdf(x, w, ..., name = "")

# S3 method for default prepCdf(x, w, ..., name = "")

Value

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

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.

Author

Andreas Alfons

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} ).\)

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

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
if (FALSE) {
## 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))
}

Run the code above in your browser using DataLab