make_initial_popn: Generate random initial population based on an expected...

Description Usage Arguments Details Value See Also Examples

View source: R/make_initial_popn.R

Description

Randomly enerate an initial population based on expected population counts.

Usage

1
make_initial_popn(expected_popn, poisson = FALSE, sd = 0)

Arguments

expected_popn

A Counts array giving expected population counts by age and sex. Typically created using functions make_stationary_popn, or make_stable_popn.

poisson

If TRUE

sd

A non-negative number, defaulting to 0. Governs extra variability in initial population, on top of Poisson variability.

Details

When poisson is TRUE (the default) the initial population counts are drawn from Poisson distributions centered at the expected values, with some extra variation. If c_{a,s} is the expected population size for age group a and sex s, then the initial population is generated using

n_{a,s} \sim Poisson(v_{a,s} c_{a, s})

where

\log(v_{a,s}) \sim N(0, b^2)

. A value for b, which may be 0, is supplied by the user, via the sd argument.

When poisson is FALSE, the initial population counts are obtained simply by rounding the expected values to the nearest integer.

Value

A Counts object, with the same dimensions as expected_popn.

See Also

make_stationary_popn

Examples

1
2
3
4
5
6
7
8
9
Lx <- dembase::Counts(Lx_west[ , , 20])
expected_popn <- make_stationary_popn(popn_size = 100,
                                    Lx = Lx,
                                    sex_ratio = 105)
make_initial_popn(expected_popn = expected_popn)
make_initial_popn(expected_popn = expected_popn,
                  sd = 0.05)
make_initial_popn(expected_popn = expected_popn,
                  poisson = FALSE)

johnrbryant/agesim documentation built on Dec. 31, 2021, 11:56 a.m.