This function produces an MCMC sample from the posterior distributions of the subpopulation size parameters from an NSUM model.
1 2 3 
dat 
a matrix of nonnegagtive integers, the 
known 
a vector of positive numbers, the sizes of known subpopulations. 
N 
a positive number, the (known) total population size. 
indices.k 
a vector of positive integers, the indices of the columns of 
iterations 
a positive integer, the total number of MCMC iterations after burnin, with default 1000. 
burnin 
a nonnegative integer, the number of burnin MCMC iterations, with default 100. 
size 
a positive integer, the number of MCMC iterations kept after thinning, with default equal to 
model 
a character string, the model to be simulated from. This must be one of 
... 
additional arguments to be passed to methods, such as starting values, prior parameters, and tuning parameters. Many methods will accept the following arguments:

The function nsum.mcmc
allows for the estimation of the various parameters from a random degree model based upon the Network Scale Up Method (NSUM) by producing Markov chain Monte Carlo (MCMC) samples from their posterior distributions. Options allow for the inclusion of barrier and transmission effects, both separately and combined, resulting in four models altogether. A large number of iterations may be required for accurate inference due to slow mixing, so the resulting chain can be thinned using the size
argument. It should be noted that subpopulation size estimation in the presence of transmission bias can be greatly improved when the priors for the multipliers tauK
are highly informative.
A list with up to nine components:
NK.values 
a matrix of positive numbers with a row for each unknown subpopulation, the thinned MCMC chains representing the posterior distributions of the sizes of the unknown subpopulations. 
d.values 
a matrix of positive numbers with a row for each individual, the thinned MCMC chains representing the posterior distributions of the network degrees. 
mu.values 
a vector of real numbers, the thinned MCMC chain representing the posterior distribution of the location parameter of the lognormal distribution of network degrees. 
sigma.values 
a vector of positive numbers, the thinned MCMC chain representing the posterior distribution of the scale parameter of the lognormal distribution of network degrees. 
rho.values 
a matrix of numbers between 0 and 1 with a row for each subpopulation, known and unknown, the thinned MCMC chains representing the posterior distributions of the dispersion parameters for the barrier effects. 
tauK.values 
a matrix of numbers between 0 and 1 with a row for each unknown subpopulation, the thinned MCMC chains representing the posterior distributions of the multipliers for the transmission biases. 
q.values 
a threedimensional array of numbers between 0 and 1 with a row for each pairing of individual and subpopulation, the thinned MCMC chains representing the binomial probabilities of the number of people that the individual knows from the subpopulation. 
NK.values 
a matrix of positive numbers with a row for each unknown subpopulation, the thinned MCMC chains representing the posterior distributions of the sizes of the unknown subpopulations. 

a positive integer, the total number of MCMC iterations after burnin. 

a nonnegative integer, the number of burnin MCMC iterations. 
Rachael Maltiel and Aaron J. Baraff
Maintainer: Aaron J. Baraff <ajbaraff at uw.edu>
Maltiel, R., Raftery, A. E., McCormick, T. H., and Baraff, A. J., "Estimating Population Size Using the Network Scale Up Method." CSSS Working Paper 129. Retrieved from https://www.csss.washington.edu/Papers/2013/wp129.pdf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  ## load data
data(McCarty)
## simulate from model with barrier effects
sim.bar < with(McCarty, nsum.simulate(100, known, unknown, N, model="barrier",
mu, sigma, rho))
## estimate unknown population size
dat.bar < sim.bar$y
mcmc < with(McCarty, nsum.mcmc(dat.bar, known, N, model="barrier", iterations=100,
burnin=50))
## view posterior distribution of subpopulation sizes for the first subpopulation
hist(mcmc$NK.values[1,])
## view posterior distribution of barrier effect parameters for the first subpopulation
hist(mcmc$rho.values[1,])

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.