postNt: Posterior mean, median, and mode for the number of...

Description Usage Arguments Details Value See Also Examples

Description

Compute the posterior mean, median, and mode for the number of individuals generating posterior distribution according to the hierarchical model.

Usage

1
2
3
4
postNt(nMNOmat, nReg, fu, fv, flambda, distNames, variation, scale = 1,
  n = 1000, relTol = 1e-06, nSim = 1000, nStrata = c(1, 100),
  verbose = FALSE, nThreads = RcppParallel::defaultNumThreads(),
  alpha = 0.05)

Arguments

nMNOmat

transition matrix with the number of individuals displaced from cell to cell detected by the Mobile Network Operator

nReg

non-negative integer vector with the number of individuals detected in each cell according to the population register

fu,

fv named lists with the prior marginal distributions of the two-dimensional points for the Monte Carlo integration

flambda

named list with the prior distribution of the lambda parameter

distNames

character vector with the names of the prior distributions for each cell

variation

list of lists whose components are parameters providing a measure of variation of each prior distribution

scale

numeric vector with the scale to count the number of individuals. Default value is 1

n

number of points to generate in the posterior distribution for the computation. Default value is 1e3

relTol

relative tolerance in the computation of the kummer function. Default value is 1e-6

nSim

number of two-dimensional points to generate to compute the integral. Default value is 1e4

nStrata

integer vector of length 2 with the number of strata in each dimension. Default value is c(1, 1e2)

verbose

logical (default FALSE) to report progress of the computation

nThreads

number (default the number of all cores, including logical cores) to use for computation

alpha

the significance level for accuracy measures. Default value is 0.05

Details

The prior distributions are specified as named lists where the first component of each list must be the name of distribution ('unif', 'triang', 'degen', 'gamma') and the rest of components must be named according to the name of the parameters of the random generator of the corresponding distribution according to:

Value

postNt computes the posterior mean, median, and mode of the posterior distribution for each cell at an arbitrary time t. The function returns a matrix with the estimates in columns and the cells in rows.

See Also

rNt, postN0, postNtcondN0

Examples

 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
## First, the inputs:

#The transition matrix of individuals detected by the MNO
nMNOmat <- rbind(c(10, 3, 4), c(5, 21, 3), c(3, 9, 18))

# Population at the initial time of each cell according to the population register
nReg <- c(90, 130, 101)

# List of priors for u
u0 <- rowSums(nMNOmat) / nReg
cv_u0 <- 0.15
fu <- lapply(u0, function(u){
 umin <- max(0, u - cv_u0 * u)
 umax <- min(1, u + cv_u0 * u)
 output <- list('unif', xMin = umin, xMax = umax)
 return(output)
})

# List of priors for v
v0 <- nReg
cv_v0 <- 0.10
fv <- lapply(v0, function(u){
  umin <- max(0, u - cv_v0 * u)
  umax <- u + cv_v0 * u
  output <- list('unif', xMin = umin, xMax = umax)
  return(output)
})

# List of priors for lambda
cv_lambda <- 0.6
alpha <- 1 / cv_lambda**2 - 1
flambda <- lapply(v0, function(v){list('gamma', shape = 1 + alpha, scale = v / alpha)})

# Names and parameters of priors for the transition probabilities
distNames <- rep('unif', 3)
variation <- rep(list(list(cv = 0.20)), 3)

# It takes a couple of minutes.
postNt(nMNOmat, nReg, fu, fv, flambda, distNames, variation)

MobilePhoneESSnetBigData/pestim documentation built on May 31, 2019, 2:44 p.m.