View source: R/simComponents.R
simComponents | R Documentation |
Simulate components of continuous variables of population data by resampling fractions from survey data. The continuous variable to be split and any categorical conditioning variables need to be simulated beforehand.
simComponents(
simPopObj,
total = "netIncome",
components = c("py010n", "py050n", "py090n", "py100n", "py110n", "py120n", "py130n",
"py140n"),
conditional = c(getCatName(total), "pl030"),
replaceEmpty = c("sequential", "min"),
seed
)
simPopObj |
a |
total |
a character string specifying the continuous variable of dataP that should be split into components. Currently, only one variable can be split at a time. |
components |
a character vector specifying the components in
|
conditional |
an optional character vector specifying categorical
conditioning variables for resampling. The fractions occurring in
|
replaceEmpty |
a character string; if |
seed |
optional; an integer value to be used as the seed of the random number generator, or an integer vector containing the state of the random number generator to be restored. |
An object of class simPopObj
containing survey
data as well as the simulated population data including the components of
the continuous variable specified by total
and components
.
The basic household structure, any categorical conditioning variables
and the continuous variable to be split need to be simulated beforehand with
the functions simStructure
, simCategorical
and
simContinuous
.
Stefan Kraft and Andreas Alfons and Bernhard Meindl
B. Meindl, M. Templ, A. Kowarik, O. Dupriez (2017) Simulation of Synthetic Populations for Survey Data Considering Auxiliary Information. Journal of Statistical Survey, 79 (10), 1–38. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v079.i10")}
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. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/02664763.2013.859237")}
simStructure
, simCategorical
,
simContinuous
, simEUSILC
data(eusilcS)
## Not run:
## approx. 20 seconds computation time
inp <- specifyInput(data=eusilcS, hhid="db030", hhsize="hsize",
strata="db040", weight="db090")
simPopObj <- simStructure(data=inp, method="direct",
basicHHvars=c("age", "rb090", "hsize", "pl030", "pb220a"))
simPopObj <- simContinuous(simPopObj, additional = "netIncome",
regModel = ~rb090+hsize+pl030+pb220a+hsize,
method="multinom", upper=200000, equidist=FALSE, nr_cpus=1)
# categorize net income for use as conditioning variable
sIncome <- manageSimPopObj(simPopObj, var="netIncome", sample=TRUE, set=FALSE)
sWeight <- manageSimPopObj(simPopObj, var="rb050", sample=TRUE, set=FALSE)
pIncome <- manageSimPopObj(simPopObj, var="netIncome", sample=FALSE, set=FALSE)
breaks <- getBreaks(x=unlist(sIncome), w=unlist(sWeight), upper=Inf, equidist=FALSE)
simPopObj <- manageSimPopObj(simPopObj, var="netIncomeCat", sample=TRUE,
set=TRUE, values=getCat(x=unlist(sIncome), breaks))
simPopObj <- manageSimPopObj(simPopObj, var="netIncomeCat", sample=FALSE,
set=TRUE, values=getCat(x=unlist(pIncome), breaks))
# simulate net income components
simPopObj <- simComponents(simPopObj=simPopObj, total="netIncome",
components=c("py010n","py050n","py090n","py100n","py110n","py120n","py130n","py140n"),
conditional = c("netIncomeCat", "pl030"), replaceEmpty = "sequential", seed=1 )
class(simPopObj)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.