condSim: condSim

Description Usage Arguments Value See Also Examples

Description

Carry out conditional simulation on a matrix of pixel-level value simulations to calculate overall or regional estimates of metrics, such total case numbers, prevalences or inequality metrics

Usage

1
condSim(vals, weights = NULL, group = NULL, fun = NULL, ...)

Arguments

vals

a matrix of samples of pixel-level values where each row corresponds to a different pixels and each column to a different posterior sample

weights

an optional vector of weights in each cell, corresponding to the rows of vals.

group

an optional vector (of the same size as weights) identifying the group (e.g. an admin unit) to which each pixel belongs. If specified, samples of case counts are calculated for each unique value of group. If group = NULL, samples are returned as the total over all pixels.

fun

function to summarise the (weighted) elements of vals, within each group, for each sample. This function must accept a vector of elements of vals as its first argument, and a vector of weights (of the same length) via an argument named weights. The default, fun = NULL, efficiently calculates a weighted sum across groups using a dot product. This does not modify the weights, so, for example, passing prevalence estimates as vals and pixel populations as weights returns the expected number of cases for each element of group for each draw.

...

other arguments to be passed to fun.

Value

If group = NULL, a vector of size equal to the number of columns in vals, each element giving a different simulated summary across all pixels covered by vals. If group is specified, a matrix of simulated summaries with each row corresponding to a different unique value in group (e.g. an administrative unit) and each column corresponding to a different draw.

See Also

Other GIS: bufferMask, getArea, getPoints, insertRaster, ll2cart, makeVoronoiPolygons, safeMask, sortPolyData

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# make some fake prevalence map data
n_pixels <- 100
n_draws <- 10
prevalence <- matrix(runif(n_pixels * n_draws),
                     ncol = n_draws)
population <- rpois(n_pixels, 100)

# run overall simulation
draws <- condSim(prevalence, population)

# simulate by (made up) country to get the expected number of infections
country <- sample(letters[1:5], n_pixels, replace = TRUE)
draws <- condSim(prevalence, population, country)

SEEG-Oxford/seegMBG documentation built on May 9, 2019, 11:08 a.m.