Sample households from given microdata.

Share:

Description

The function samples households from microdata containing personal and household information.

Usage

1
2
sampHH(pop, sizefactor = 1, hid = "hid", strata = "region",
  hsize = NULL)

Arguments

pop

data frame containing households and persons

sizefactor

factor of how many times the initial population should be resampled

hid

string specifying the name of the household-id variable in the data.

strata

can be used to sample within strata.

hsize

string specifying the name of the household size variable in the data.

Details

households are drawn from the data and new ID's are generated for the new households.

Value

the data frame of new households.

Author(s)

Bernhard Meindl, Matthias Templ and Johannes Gussenbauer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data(eusilcP)
pop <- eusilcP
colnames(pop)[3] <- "hhsize"

system.time(x1 <- sampHH(pop, strata="region", hsize="hhsize"))
dim(x1)
## Not run: 
## approx. 10 second computation time ...
system.time(x1 <- sampHH(pop, sizefactor=4, strata="region", hsize="hhsize"))
dim(x1)
system.time(x2 <- sampHH(pop, strata=NULL, hsize="hhsize"))

pop <- pop[,-which(colnames(pop)=="hhsize")]
system.time(y1 <- sampHH(pop, strata="region", hsize=NULL))
system.time(y2 <- sampHH(pop, strata=NULL, hsize=NULL))

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.