Learn R Programming

simPop (version 0.3.0)

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

Value

An object of class "trellis", as returned by 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$.$

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
## 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)

Run the code above in your browser using DataLab