Description Usage Arguments Value Details on priors References See Also Examples
View source: R/posteriorsize.R
posteriorsize
computes the posterior distribution of the
population size based on data collected by Respondent Driven Sampling. The
approach approximates the RDS via the Sequential Sampling model of Gile
(2008). As such, it is referred to as the Sequential Sampling  Population Size Estimate (SSPSE).
It uses the order of selection of the sample to provide information
on the distribution of network sizes over the population members.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21  posteriorsize(s, s2 = NULL, rc = rep(FALSE, length(s2)),
median.prior.size = NULL, interval = 10, burnin = 5000, maxN = NULL,
K = NULL, samplesize = 1000, quartiles.prior.size = NULL,
mean.prior.size = NULL, mode.prior.size = NULL,
priorsizedistribution = c("beta", "flat", "nbinom", "pln", "supplied"),
effective.prior.df = 1, sd.prior.size = NULL,
mode.prior.sample.proportion = NULL, alpha = NULL,
degreedistribution = c("cmp", "nbinom", "pln"), mean.prior.degree = NULL,
sd.prior.degree = NULL, max.sd.prior.degree = 4, df.mean.prior = 1,
df.sd.prior = 3, beta0.mean.prior = 3, beta1.mean.prior = 0,
beta0.sd.prior = 10, beta1.sd.prior = 10, mem.optimism.prior = 1,
df.mem.optimism.prior = 5, mem.sd.prior = 5, df.mem.sd.prior = 3,
visibility = FALSE, type.impute = c("mode", "distribution", "median",
"mean"), Np = 0, nk = NULL, n = NULL, n2 = length(s2),
muproposal = 0.1, sigmaproposal = 0.15, beta0proposal = 0.2,
beta1proposal = 0.001, memmuproposal = 0.1, memsdproposal = 0.15,
burnintheta = 500, burninbeta = 50, parallel = 1,
parallel.type = "PSOCK", seed = NULL, maxbeta = 120,
supplied = list(maxN = maxN), max.coupons = NULL, recruit.time = NULL,
include.tree = TRUE, unit.scale = FALSE, optimism = TRUE,
reflect.time = TRUE, verbose = TRUE)

s 
either a vector of integers or an 
s2 
vector of integers; optionally, the vector of degrees from a second RDS, subsequent to the first RDS recorded in s. These are also in the order they are recorded. 
rc 
vector of logicals; optionally, a vector of the same length as s2 indicating if the corresponding unit was sampled in the first RDS. 
median.prior.size 
scalar; A hyperparameter being the mode of the prior distribution on the population size. 
interval 
count; the number of proposals between sampled statistics. 
burnin 
count; the number of proposals before any MCMC sampling is done. It typically is set to a fairly large number. 
maxN 
integer; maximum possible population size. By default this is determined from an upper quantile of the prior distribution. 
K 
count; the maximum degree for an individual. This is usually
calculated as 
samplesize 
count; the number of MonteCarlo samples to draw to compute the posterior. This is the number returned by the MetropolisHastings algorithm.The default is 1000. 
quartiles.prior.size 
vector of length 2; A pair of hyperparameters
being the lower and upper quartiles of the prior distribution on the
population size. For example, 
mean.prior.size 
scalar; A hyperparameter being the mean of the prior distribution on the population size. 
mode.prior.size 
scalar; A hyperparameter being the mode of the prior distribution on the population size. 
priorsizedistribution 
character; the type of parametric distribution
to use for the prior on population size. The options are 
effective.prior.df 
scalar; A hyperparameter being the effective number of samples worth of information represented in the prior distribution on the population size. By default this is 1, but it can be greater (or less!) to allow for different levels of uncertainty. 
sd.prior.size 
scalar; A hyperparameter being the standard deviation of the prior distribution on the population size. 
mode.prior.sample.proportion 
scalar; A hyperparameter being the mode of the prior distribution on the sample proportion n/N. 
alpha 
scalar; A hyperparameter being the first parameter of the beta prior model for the sample proportion. By default this is NULL, meaning that 1 is chosen. it can be any value at least 1 to allow for different levels of uncertainty. 
degreedistribution 
count; the parametric distribution to use for the
individual network sizes (i.e., degrees). The options are 
mean.prior.degree 
scalar; A hyper parameter being the mean degree for the prior distribution for a randomly chosen person. The prior has this mean. 
sd.prior.degree 
scalar; A hyper parameter being the standard deviation of the degree for a randomly chosen person. The prior has this standard deviation. 
max.sd.prior.degree 
scalar; The maximum allowed value of 
df.mean.prior 
scalar; A hyper parameter being the degreesoffreedom of the prior for the mean. This gives the equivalent sample size that would contain the same amount of information inherent in the prior. 
df.sd.prior 
scalar; A hyper parameter being the degreesoffreedom of the prior for the standard deviation. This gives the equivalent sample size that would contain the same amount of information inherent in the prior for the standard deviation. 
beta0.mean.prior 
scalar; A hyper parameter being the mean of the beta0 parameter distribution in the model for the number of recruits. 
beta1.mean.prior 
scalar; A hyper parameter being the mean of the beta1 parameter distribution in the model for the number of recruits. 
beta0.sd.prior 
scalar; A hyper parameter being the standard deviation of the beta0 parameter distribution in the model for the number of recruits. 
beta1.sd.prior 
scalar; A hyper parameter being the standard deviation of the beta0 parameter distribution in the model for the number of recruits. 
mem.optimism.prior 
scalar; A hyper parameter being the mean of the distribution of the optimism parameter. 
df.mem.optimism.prior 
scalar; A hyper parameter being the degreesoffreedom of the prior for the optimism parameter. This gives the equivalent sample size that would contain the same amount of information inherent in the prior. 
mem.sd.prior 
scalar; A hyper parameter being the mean of the distribution of the dispersion parameter in the visibility model. 
df.mem.sd.prior 
scalar; A hyper parameter being the degreesoffreedom of the prior for the standard deviation of the dispersion parameter in the visibility model. This gives the equivalent sample size that would contain the same amount of information inherent in the prior for the standard deviation. 
visibility 
logical; Indicate if the measurement error model
is to be used, whereby latent visibilities are used in place of the reported
network sizes as the unit size variable. If 
type.impute 
The type of imputation to use for the summary visibilities
(returned in the component 
Np 
integer; The overall degree distribution is a mixture of the

nk 
vector; the vector of counts for the number of people in the
sample with degree k. This is usually computed from s automatically as

n 
integer; the number of people in the sample. This is usually computed from s automatically and not usually specified by the user. 
n2 
integer; If s2 is specified, this is the number of people in the second sample. This is usually computed from s automatically and not usually specified by the user. 
muproposal 
scalar; The standard deviation of the proposal distribution for the mean degree. 
sigmaproposal 
scalar; The standard deviation of the proposal distribution for the standard deviation of the degree. 
beta0proposal 
scalar; The standard deviation of the proposal distribution for the beta0 parameter of the recruit model. 
beta1proposal 
scalar; The standard deviation of the proposal distribution for the beta1 parameter of the recruit model. 
memmuproposal 
scalar; The standard deviation of the proposal distribution for the log of the optimism parameter (that is, gamma). 
memsdproposal 
scalar; The standard deviation of the proposal distribution for the log of the s.d. in the optimism model. 
burnintheta 
count; the number of proposals in the MetropolisHastings substep for the degree distribution parameters (θ) before any MCMC sampling is done. It typically is set to a modestly large number. 
burninbeta 
count; the number of proposals in the MetropolisHastings substep for the visibility distribution parameters (β) before any MCMC sampling is done. It typically is set to a modestly large number. 
parallel 
count; the number of parallel processes to run for the MonteCarlo sample. This uses MPI or PSOCK. The default is 1, that is not to use parallel processing. 
parallel.type 
The type of parallel processing to use. The options are "PSOCK" or "MPI". This requires the corresponding type to be installed. The default is "PSOCK". 
seed 
integer; random number integer seed. Defaults to 
maxbeta 
scalar; The maximum allowed value of the 
supplied 
list; If supplied, is a list with components 
max.coupons 
The number of recruitment coupons distributed to each enrolled subject (i.e. the maximum number of recruitees for any subject). By default it is taken by the attribute or data, else the maximum recorded number of coupons. 
recruit.time 
vector; An optional value for the data/time that the person was interviewed. It needs to resolve as a numeric vector with number of elements the number of rows of the data with nonmissing values of the network variable. If it is a character name of a variable in the data then that variable is used. If it is NULL then the sequence number of the recruit in the data is used. If it is NA then the recruitment is not used in the model. Otherwise, the recruitment time is used in the model to better predict the visibility of the person. 
include.tree 
logical; If 
unit.scale 
numeric; If not 
optimism 
logical; If 
reflect.time 
logical; If 
verbose 
logical; if this is 
posteriorsize
returns a list consisting of the
following elements:
pop 
vector; The final posterior draw for the degrees of the population. The first n are the sample in sequence and the reminder are nonsequenced. 
K 
count; the maximum degree for an individual. This is usually calculated as twice the maximum observed degree. 
n 
count; the sample size. 
samplesize 
count; the number of MonteCarlo samples to draw to compute the posterior. This is the number returned by the MetropolisHastings algorithm.The default is 1000. 
burnin 
count; the number of proposals before any MCMC sampling is done. It typically is set to a fairly large number. 
interval 
count; the number of proposals between sampled statistics. 
mu 
scalar; The
hyper parameter 
sigma 
scalar; The hyper parameter 
df.mean.prior 
scalar; A hyper parameter being the degreesoffreedom of the prior for the mean. This gives the equivalent sample size that would contain the same amount of information inherent in the prior. 
df.sd.prior 
scalar; A hyper parameter being the degreesoffreedom of the prior for the standard deviation. This gives the equivalent sample size that would contain the same amount of information inherent in the prior for the standard deviation. 
Np 
integer; The
overall degree distribution is a mixture of the 
muproposal 
scalar; The standard deviation of the proposal distribution for the mean degree. 
sigmaproposal 
scalar; The standard deviation of the proposal distribution for the standard deviation of the degree. 
N 
vector of length 5; summary statistics for the posterior population size.

maxN 
integer; maximum possible population size. By default this is determined from an upper quantile of the prior distribution. 
sample 
matrix of dimension

sample 
matrix of dimension 
lpriorm 
vector; the vector of (log) prior
probabilities on each value of m=Nn  that is, the number of
unobserved members of the population. The values are

burnintheta 
count; the number of proposals in the MetropolisHastings substep for the degree distribution parameters (θ) before any MCMC sampling is done. It typically is set to a modestly large number. 
verbose 
logical; if this is

predictive.degree.count 
vector; a vector
of length the maximum degree ( 
predictive.degree 
vector; a vector of length the maximum degree
( 
MAP 
vector of length 6
of MAP estimates corresponding to the output

mode.prior.sample.proportion 
scalar; A hyperparameter being the mode of the prior distribution on the sample proportion n/N. 
median.prior.size 
scalar; A hyperparameter being the mode of the prior distribution on the population size. 
mode.prior.size 
scalar; A hyperparameter being the mode of the prior distribution on the population size. 
mean.prior.size 
scalar; A hyperparameter being the mean of the prior distribution on the population size. 
quartiles.prior.size 
vector of length 2; A pair of hyperparameters being the lower and upper quartiles of the prior distribution on the population size. 
degreedistribution 
count; the
parametric distribution to use for the individual network sizes (i.e.,
degrees). The options are 
priorsizedistribution 
character; the type of parametric distribution
to use for the prior on population size. The options are 
The best way to specify the prior is via the
hyperparameter mode.prior.size
which specifies the mode of the prior
distribution on the population size. You can alternatively specify the
hyperparameter median.prior.size
which specifies the median of the
prior distribution on the population size, or mean.prior.sample
proportion
which specifies the mean of the prior distribution on the
proportion of the population size in the sample or mode.prior.sample
proportion
which specifies the mode of the prior distribution on the
proportion of the population size in the sample. Finally, you can specify
quartiles.prior.size
as a vector of length 2 being the pair of lower
and upper quartiles of the prior distribution on the population size.
Gile, Krista J. (2008) Inference from PartiallyObserved Network Data, Ph.D. Thesis, Department of Statistics, University of Washington.
Gile, Krista J. and Handcock, Mark S. (2010) RespondentDriven Sampling: An Assessment of Current Methodology, Sociological Methodology 40, 285327.
Gile, Krista J. and Handcock, Mark S. (2014) sspse: Estimating Hidden Population Size using Respondent Driven Sampling Data R package, Los Angeles, CA. Version 0.5, http://hpmrg.org.
Handcock MS (2003). degreenet: Models for Skewed Count Distributions Relevant to Networks. Statnet Project, Seattle, WA. Version 1.2, http://statnetproject.org.
Handcock, Mark S., Gile, Krista J. and Mar, Corinne M. (2014) Estimating Hidden Population Size using RespondentDriven Sampling Data, Electronic Journal of Statistics, 8, 1, 14911521
Handcock, Mark S., Gile, Krista J. and Mar, Corinne M. (2015) Estimating the Size of Populations at High Risk for HIV using RespondentDriven Sampling Data, Biometrics.
network, statnet, degreenet
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  N0 < 200
n < 100
K < 10
# Create probabilities for a Waring distribution
# with scaling parameter 3 and mean 5, but truncated at K=10.
probs < c(0.33333333,0.19047619,0.11904762,0.07936508,0.05555556,
0.04040404,0.03030303,0.02331002,0.01831502,0.01465201)
probs < probs / sum(probs)
#
# Create a sample
#
set.seed(1)
pop<sample(1:K, size=N0, replace = TRUE, prob = probs)
s<sample(pop, size=n, replace = FALSE, prob = pop)
# Here interval=1 so that it will run faster. It should be higher in a
# real application.
out < posteriorsize(s=s,interval=1)
plot(out, HPD.level=0.9,data=pop[s])
summary(out, HPD.level=0.9)
# Let's look at some MCMC diagnostics
plot(out, HPD.level=0.9,mcmc=TRUE)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.