sim_pop | R Documentation |
This function can be used to generate population data from a data generating process for testing downscaling.
sim_pop(
n,
J = 2,
tt = 2,
k = 2,
alphas = matrix(stats::runif(tt * (J - 1)), tt, J) * 2,
xmat = matrix(stats::rnorm(n * k), n, k),
betas = matrix(stats::rnorm(k * J), k, J)
)
n |
Number of spatial observations |
J |
Number of population types |
tt |
Number of time steps to simulate |
k |
Number of covariates to simulate |
alphas |
Matrix of dimensions |
xmat |
Matrix of dimensions |
betas |
Matrix of dimensions |
The generated Poisson model over J
distinct population tyes
(with j',j = 1,...,J
) takes the form:
y_{ijt} = \exp{\exp(\alpha_{jt} + X_i \beta_{j})}
with X_i
being the i
-th row of the n \times k
matrix X
. \beta_j
is the
k \times J
matrix of population type specific slope parameters. \alpha_{jt}
are population type
specific intercepts, which are typically optimised using the bias correction method. These are assumed
to vary over time.
The function generates the NT \ times J
matrix Y
. Based on this, the function
generates a set of targets T_{jt}
for downscaling. These are calculated by:
T_{jt} = \sum^n_{i=1} y_{ijt}
The output of this function can be directly used in downscale_pop
.
A list with the generated \alpha
(alphas
), X
(xmat
),
\beta
(betas
), Y
(Y
),
and T
(targets
). The returned values are in long format as required by
downscale_pop
.
dgp1 = sim_pop(n = 100)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.