Learn R Programming

simPop (version 0.3.0)

simple_dis: Simple generation of new variables

Description

Fast simulation of new variables based on univariate distributions

Usage

univariate.dis(puf, data, additional, weights, value = "data", fNA = NA)
conditional.dis(puf, data, additional, conditional, weights, value = "data", fNA = NA)

Arguments

puf
data for which one additional column specified by function argument ‘additional’ is simulated
data
donor data
additional
name of variable to be simulated
weights
sampling weights from data
value
if “data” then the puf including the additional variable is returned, otherwise only the simulated vector.
fNA
only used with missing values if another code as NA should be used
conditional
conditioning variable

Details

Function uni.distribution: random draws from the weighted univariate distribution of the original data

Function conditional.dis: random draws from the weighted conditional distribution (conditioned on a factor variable)

This are simple functions to produce structural variables, variables that should have the same categories as given ones. For more advanced methods see simCategorical()

See Also

simCategorical

Examples

Run this code
## we don't have original data, so let's use eusilc
data(eusilc13puf)
data(eusilcS)
v1 <- univariate.dis(eusilcS, eusilc13puf, additional = "db040",
weights = "rb050", value = "vector")
table(v1)
table(eusilc13puf$db040)
## we don't have original data, so let's use eusilc
##data(eusilc13puf)
##data(eusilcS)
##v1 <- conditional.dis(eusilcS, eusilc13puf, additional = "pb190",
##  conditional = "db040", weights = "rb050")
##table(v1) / sum(table(v1))
##table(eusilc13puf$pb190) / sum(table(eusilc13puf$pb190))

Run the code above in your browser using DataLab