Description Usage Arguments Details See Also Examples
Function for the simulation framework in GAIL. Determined the spatial unit (both regular and irregular) into which a population individual falls, and randomly samples whether an individual is case vs non-case and whether an individual is in regular or non-regular spatial unit.
1 | gail_sim_assign(units_reg, units_irr, loca_pop, seed = NULL)
|
units_reg |
Set of regular spatial units |
units_irr |
Set of irregular spatial units |
loca_pop |
True locations of the population |
seed |
If given, sets the seed for the RNG. |
The argument units_reg
must have columns case_rate
and rural_rate
. These will
ordinarily be generated by other simulation functions in the process of simulating
the data.
This function assigns case/non and regular/irregular by:
Assigning entire population to the regular spatial units
For each regular spatial unit, independently sampling based on case rate (to generate cases) and rural rate (to generate individuals reporting the irregular spatial unit).
gail_sim_regions, gail_sim_rate, gail_sim_pop, gail_sim_index
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | ## Not run:
## Generate Regions
loca_reg <- gail_gen_regions( npoints=40, type="regular", nedge=10, suid="reg" )
loca_irr <- gail_gen_regions( npoints=40, type="regular", nedge=10, suid="reg" )
## Generate incidence rate
rate_spec <- data.frame(
mx = c(25, 60),
my = c(25, 80),
ax = c(10, 40),
ay = c(25, 20),
efc = c( 0.15 , 4.0 )
)
loca_reg[["case_rate"]] <- gail_sim_rate( loca_reg, rate_base=c(0.03,0.07),
rate_spec=rate_spec, seed=42 )
## Generate rate of being in irregular locations
irr_spec <- data.frame(
mx = c(85, 20, 25, 60),
my = c(15, 80, 25, 80),
ax = c(20, 10, 10, 40),
ay = c(20, 20, 25, 20),
efc = c(4.0, 4.0, 0.15 , 0.15 )
)
loca_reg[["rural_rate"]] <- gail_sim_rate( loca_reg, rate_base=c(0.03,0.07),
rate_spec=rate_spec, seed=42 )
## Generate population
beta_setup <- data.frame(
nn=c(5000, 1000, 500),
mx=c(50, 25, 60),
my=c(50, 25, 80),
sx=c(30, 10, 10),
sy=c(30, 10, 5)
)
loca_pop <- gail_sim_pop( loca_reg, loca_irr, method="beta",
beta_setup=beta_setup, seed=42 )
## Simulate index
loca_reg[["index"]] <- gail_sim_index( loca_reg, tau=1.5, phi=0.05 )
loca_irr[["index"]] <- gail_sim_index( loca_irr, tau=1.5, phi=0.05 )
## Assign cases and spatial unit
gsa01 <- gail_sim_assign( loca_reg, loca_irr, loca_pop, seed=42 )
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.