{'fraction_non_alphanumeric': 0.035839127261552646, 'fraction_numerical': 0.01452003226673837, 'mean_word_length': 4.60594315245478, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A sample size heuristic for network scale-up studies

The network scale-up method (NSUM) is a survey-based method for estimating the number of individuals in a hidden or hard-to-reach subgroup of a general population. In NSUM surveys, sampled individuals report how many others they know in the subpopulation of interest (e.g."How many sex workers do you know?") and how many others they know in subpopulations of the general population (e.g."How many bus drivers do you know?"). NSUM is widely used to estimate the size of important epidemiological risk groups, including men who have sex with men, sex workers, HIV+ individuals, and drug users. Unlike several other methods for population size estimation, NSUM requires only a single random sample and the estimator has a conveniently simple form. Despite its popularity, there are no published guidelines for the minimum sample size calculation to achieve a desired statistical precision. Here, we provide a sample size formula that can be employed in any NSUM survey. We show analytically and by simulation that the sample size controls error at the nominal rate and is robust to some forms of network model mis-specification. We apply this methodology to study the minimum sample size and relative error properties of several published NSUM surveys.

As Maltiel et al. [46] summarized, "NSUM is based on the idea that for all individuals, the probability of knowing someone in a given subpopulation is the size of that subpopulation divided by the overall population size." In the basic NSUM [47][48][49][50], investigators obtain a single random sample of individuals in the general population, who are not necessarily members of the hidden population. Each respondent reports the number of others they know in the general population (or the number they know in several subgroups of the general population so that the number of others they know in the general population may be estimated) and also the number they know in the target population. The ratio of these average counts is multiplied by the known size of the general population to estimate the size of the target population.
Population size estimation using NSUM relies on several assumptions related to homogeneity of the underlying network of acquaintanceships and the accuracy of reported counts. Several variants and generalizations of NSUM extend the method to accommodate more flexible assumptions using complex estimators. For example, McCormick and Zheng [51] provide an adjustment for recall bias, in which the number of contacts is underestimated in large groups and overestimated in small groups. Habecker et al. [52] and Feehan and Salganik [53] formalize the incorporation of unequal sampling weights for surveyed individuals into NSUM. Maltiel et al. [46] propose a Bayesian approach that models recall bias, transmission error, and barrier effects directly. Feehan and Salganik [53] introduce a method that generalizes NSUM (called G-NSUM) by recognizing that in an undirected network, total in-degrees and out-degrees must be equal, a fact that can be exploited when two samples are obtainable. The G-NSUM was further generalized for venue-based sampling [54]. While these methods offer improved and more efficient estimates, the classic NSUM method remains widely used due to its simplicity.
As NSUM surveys grow in popularity, practitioners need guidance on how to design NSUM studies to achieve accurate and reliable results. Researchers have noted that population-size estimates from NSUM can have high variance [20,27,44,47]. This may be due in part to the lack of a coherent framework that guides investigators in choosing a sample size for empirical studies. To address this gap, we present a sample size heuristic that enables researchers to calculate the number of respondents needed to estimate the size of a hidden population at a given relative error. We investigate the properties of the sample size heuristic and analyze its performance under network model mis-specificiation. Finally, we perform a retrospective sample size analysis for several existing NSUM studies and conclude with recommendations for empirical NSUM study design.

Setting and NSUM estimator
Consider a set V of individuals of known size M = |V | called the general population. A subset of individuals U ⊂ V of size N = |U | comprise the hidden population; we wish to estimate N . NSUM relies on information about the network of relationships between individuals. The meaning of these relationships varies according to the type of study, but may include social, epidemiological, or communication relationships. Let G = (V, E) represent the general population network, where V is the set of individuals in the general population and E is the set of relevant relationships between population members. We assume G is undirected and simple, that is, contains no parallel edges or self-loops. Then for all i, j ∈ V , we have (i, j) ∈ E whenever i and j share the relationship of interest. Next, define d u i = |{(j, i) ∈ E, j ∈ U }| to be the number of connections to the hidden population of person i, that is, the number of links between person i and members of the hidden population U . Finally, define the personal network size of person i -which is also called i's degree -as d i = |{(j, i) ∈ E, j ∈ V }|, the number of edges incident to person i in G. For simplicity, we assume below that d i is directly observed, but in practice NSUM studies often estimate d i using the known population method [24,25] or the summation method [55].
The statistical performance of the NSUM estimator relies on assumptions about the distribution of personal network sizes d i and reported connections to the hidden population d u i that imply certain global features of the underlying general population network. In many cases, these assumptions correspond to a particular random graph model. Laga et al. [49] provides a summary of network distributional assumptions in the NSUM literature. In what follows, we assume the general population network has Erdős-Rényi distribution [56]. This framework can be extended to any vertex-exchangeable graph model [57], and we illustrate in Section 4.1, with details in Appendix C, that the sample size heuristic is robust to violations of vertex-exchangeability.
Under an Erdős-Rényi model for the network G, edge relationships exist between individuals in V , and between individuals in V and U , with probability p independently of other relationships. Consequently, the following marginal degree models for person i hold: It follows that If i is a member of the target population, then d u i ∼ Binomial(N −1, p) and E[d u i ] = (N −1)p ≈ N p.
This yields an immediate formula for N in terms of the expected general and hidden population degrees: To estimate the hidden population size N , consider a random sample of n individuals from V , each of whom reports how many individuals they know in different subgroups of the general population (which allows us to estimate d i ) and how many individuals they know in the hidden population (which is d u i ). Using this information, NSUM estimates both of the expectations in (3) empirically by averages. Then a method of moments equation for (2) is Solving for N , we arrive at the classic NSUM estimator [24], (4)

Sample size heuristic
Investigators conducting an NSUM survey must determine the minimum number of samples to collect in order to obtain a suitably precise estimate of the hidden population size N . To do this, investigators must first specify how precise they want their estimates to be. This means choosing a value for two parameters: (i) the confidence level, 1 − α; and (ii) the relative margin of error, ε. In many applied studies, researchers choose to use 95% confidence intervals to express sampling uncertainty in their estimates, meaning that α = 0.05. The relative margin of error, ε, describes how close, in relative terms, the estimate is expected to be to the population value [58]. For example, a relative margin of error of 10% (ε = 0.1) and a confidence level of 95% (α = 0.05) means that researchers want a sample size that produces estimates within 10% of the true value at least 95% of the time (that is, in at least 95% of repeated samples).
Formally, the minimum sample size is the smallest n such that where | N − N |/N is the relative absolute error of the estimate. In other words, investigators seek the smallest sample size that ensures the relative error is small with high probability.
Heuristic 1. Let the relative margin of error be ε > 0, the confidence level be 1 − α for 0 < α < 1, the prevalence of the hidden population be q = N/M , and the average personal network size be The minimum sample size n needed to satisfy (5) is then where · is the ceiling operator and z α/2 is the 1−α/2 quantile of the standard normal distribution.
In order to use the sample size formula (6), researchers must specify the values for three population quantities: (i) the size of the general population, M ; (ii) the prevalence of the hidden population, q = N/M ; and (iii) the average size of respondents' personal networks, d. Several properties of the minimum sample size can be deduced immediately from (6), and these properties can be helpful in guiding the choice of these three parameters. First, when the general population size M is large, the contribution of M to the minimum sample size in (6) is negligible. Second, the consequences of error in estimates of q and d are evident. If the prevalence of the hidden population q is under-estimated, the minimum sample size increases; if q is over-estimated, the minimum sample size increases. Therefore, it is preferable to over-estimate the prevalence to ensure a conservative sample size. If the average population degree d is under-estimated, the minimum sample size increases; if d is overestimated, the minimum sample size decreases. Therefore it may be preferable for investigators   (6) is approximately Heuristic 1 is appropriate when subjects are sampled uniformly at random from the population. In practice, NSUM surveys may employ more complex sampling designs using multi-stage sampling, clustering, and stratification. These complex design features affect the variance of estimates. One common approach to modifying the sample size heuristic in (6) is through the use of a design effect for quantifying the impact of a complex sampling design on an estimate. It is defined as the ratio of the variances of an estimator with a given sampling design to a simple random sample; if N w is an NSUM estimator with a complex sampling design, then If the design effect is known a priori, then the minimum sample size calculation from Heuristic 1 can be multiplied by it to obtain an adjusted estimate.
Heuristic 2. Let D eff be the known design effect for a given sampling scheme. The minimum sample size n needed to achieve (5) is approximately Alternatively, once a sample has been collected, an effective sample size can be computed as n eff = n D eff .

Simulation studies
We first assess the relative error and coverage rates using the minimum sample size by simulation.
We employ a factorial design that varies the population size, the prevalence, the nominal levels, and the underlying population graph model. We include i) an Erdős-Rényi network [56], ii) an exponential random graph [59], iii) a preferential attachment network [60], iv) a stochastic block model [61], and v) a small-world network [62]. Each graph model has the same expected density around 10%, which allows us to isolate the effect of the graph topology and assess the robustness to network model mis-specification, i.e. how well our minimum sample size calculation works when the underlying population graph implies degree models that violate (1).
The details and results are left to Appendix 4.1, but the conclusions are as follows. The average relative error is below the tolerated level ε for all values of M and q when the underlying graph model is ER, ERGM, and small-world. For low prevalence, PA and SBM have average relative errors that exceed the tolerance level, but this is mitigated as prevalence and population size increase. Similarly, the average coverage is conservative for ER, ERGM, and small-world across different nominal levels α, whereas it suffers for small populations with low prevalence for PA and SBM. As expected, the error bars are larger for larger values of α. Finally, the relative error and coverage drift smoothly away from the desired levels as the underlying graph model deviates from the assumption of vertex-exchangeability.

Case studies
We now conduct a retrospective sample size analysis of published empirical NSUM surveys. Each published study reports the population size M , the sample size n employed in the study, and the population size estimate N . To derive information about the marginal degree model, we assume that the degree reports d i and d u i follow (1), whered i ,d u i , and N are the estimates from the study. In other words, we take the published estimate N as the true hidden population size N . From this information, we calculate the minimum sample sizes n according to (6) using the implied average population degree and prevalence given the published value of the general population size M . We use a relative error tolerance of 10% (ε = 0.1) and 95% confidence level (α = 0.05).
Using these parameters, we compute 10,000 Monte Carlo NSUM estimates of the target population size. That is, in each replicate, we sample n degree reports d 1 , . . . , d n and d u 1 , . . . , d u n following the Binomial models in (9), and use them to calculate the NSUM estimate of N . For each replicate, we compute the relative error of our NSUM estimate compared to the published estimate in the study, and report the Monte Carlo average relative error over all 10,000 replicates, which we denote RelErr. We apply this retrospective sample size calculation to seven published NSUM studies.
First, we revisit a study by Killworth et al. [24] to estimate the number of HIV+ individuals in 1994 in the US, around the height of the AIDS crisis. Using a telephone survey, the authors randomly sampled n = 1, 554 members of the US population. Despite the above-average response rate, the authors recognized the potential for some non-response bias. However, they do not discuss why this sample size was chosen, but they report that the survey cost $6.50 per respondent and took 10 minutes to conduct, which suggests there may have been resource constraints. One of the major contributions of this study is an improved technique for estimating personal network sizes, along with one of the first reports of the distribution of network sizes for a random sample of the US population. Using these estimates, the authors concluded that a 95% confidence interval for the number of HIV+ individuals wasN = 800, 000 ± 43, 000, which was in line with estimates from the CDC on seroprevalence.
Second, we look at two applications of NSUM to estimate the number of sex workers in China [19,22]. Chongqing, the largest province in China, had its first reported HIV case in 1993. By 2011, there were nearly 12,000 reported cases, yet population estimates of key affected populations were then unknown. Citing the need for targeted interventions and resource allocation, Guo et al. [19] employed a multistage random sample of 2,957 individuals in order to obtain NSUM estimates of key populations including female sex workers (FSW). Using their survey results, the authors estimated d = 311, which had not previously been estimated in Chongqing. This led to a 95% confidence interval ofN = 31, 576 ± 1, 980 for the number of FSW. They also found that sex workers have a high respect factor, but, while they argue that this suggests their NSUM estimates are less likely to be underestimated, their estimate when adjusting for respect factor was 10% lower. Although this is an important study, being one of the first applications of NSUM in China, the authors note several limitations that ultimately bring additional uncertainty to the conclusions.
More recently, Jing et al. [22] incorporated a randomized response technique to an NSUM survey in 2012 of 7,964 individuals in Taiyuan, China. The authors estimate the FSW population to beN = 3, 866, which was similar to the more expensive multiplier methods and consistent with previously reported estimates of sex worker prevalence in Asia. The authors argue that this demonstrates the the appropriateness of their adjusted NSUM approach.
Next, we look at two applications of NSUM to estimate the number of men who have sex with men (MSM) [16,17]. Since 2008, the number of HIV cases in Japan has risen constantly, with 89% of new cases attributed to MSM. However, prior to 2012, the size of the MSM population in Japan had not been estimated "in a rigorous manner" [16]. To address this, Ezoe et al. [16] employed the first internet-based NSUM estimator. The authors surveyed 1,500 individuals who were registered to Intage, an internet-research agency. They estimated the MSM prevalence among the male population to be 2.87%, which was comparable to previous studies using the directestimation method. These results suggest that internet surveys can be combined with NSUM for an even quicker and lower-cost method, especially in stigmatized populations.
Wang et al. [17] are also interested in estimating the number of MSM, but in Shanghai, China. Instead of an internet-based survey, the authors conducted a community-based survey across 19 districts in Shanghai consisting of 3,907 participants. Using NSUM, the authors report a 95% confidence interval forN as 36, 354 ± 7, 865, but they note that "we did not take the sample design into consideration when performing variance estimation." Finally, we consider two applications of NSUM to quantify drug use [33,52]. In the first, Heydari et al. [33] are interested in estimating the number of individuals using methadone maintenance therapy (MMT) in Kerman, Iran. Such data, which was previously not available, is needed to assess the effectiveness of MMT. The authors used two cross-sectional studies with multi-stage sampling to recruit 2,550 individuals. Using NSUM, they reportN = 5, 289. Furthermore, they were able to use this to estimate the treatment failure ratio, which was a novel application of NSUM and further evidence of its widespread applicability.
Similarly, Habecker et al. [52] use NSUM to estimate the number of heroin users in Nebraska in the past 30 days. In 2014, the authors received 550 completed mail surveys, which included additional questions that allowed the authors to compute and incorporate sampling weights into an improved NSUM estimator. Such improvements are particularly important when knowledge of the scope of the problem is time-sensitive. Ultimately, this yielded an estimate of a 95% confidence interval of N = 368 ± 89 for the number of heroin users in the past 30 days, which may be a proxy for the number of current heroin users. Table 1 shows the results of the retrospective analysis on these seven studies. Figure 2 compares the actual study sample sizes and the retrospectively calculated minimum sample sizes using (6). While most of the studies have an average relative error below 0.05, Guo et al. [19] and Wang et al. [17] may have much larger relative errors. In both of these cases, the study sample size is larger than our minimum sample size, but the average hidden population degree is much smaller than the average general population degree times the prevalence. This suggests the topology of the hidden population network differs from that of the general population network, which was a specific limitation listed by Guo et al. [19]. Figure 2: Study sample size compared to the minimum sample size from (6) calculated based on each study's reported estimates of prevalence and average network size. Most of the points lie below the line y = x, suggesting that the actual sample size was larger than necessary to achieve 10% precision with 95% confidence.

Discussion
In this paper, we have presented a simple heuristic for the minimum sample size that controls relative error (6). The heuristic is easy to employ and theoretically justified under the assumption that the general population network follows the Erdős-Rényi random graph model. Furthermore, simulations show that the sample size heuristic is robust to a variety of deviations from this idealized setting.
We also demonstrated how published NSUM studies have sample sizes that scale similarly to this minimum sample size, though most have used a sample size larger than our retrospectively calculated minimum sample size, implying that they could have saved resources by administering surveys to fewer respondents. That said, since the minimum sample sizes are functions of the reported estimates of prevalence and average network degrees, which are all quite high, it is possible that this is a propagation of biased estimates. On the other hand, one of the studies has n < n min , which implies they may have low precision in their estimates of the sizes of the populations of interest. In general, practitioners appear to be intuiting our heuristic as many of the study sample sizes are on the same order of magnitude as our minimum sample sizes.
In order to use the formula (6), investigators must specify values for M , q, and d. In some cases, estimates of q and d may be based on the results of previous studies. But, if little existing information about the hidden population is available, our results show that it will be conservative to err on the side of assuming that the hidden population is relatively low in prevalence (low q) and that personal network sizes are relatively small (low d).
While our heuristic should help practitioners design future NSUM studies, there are several limitations to our analysis. First, the relative error controlled for in Heuristic 1 may not provide the desired absolute precision. Second, the normal approximation of our standardized estimator N −N √ vn may be invalid for small samples. Third, sample size formula may differ for more complex sampling designs and the design effects in Heuristic 2 for adjusting the minimum sample size may be unknown. Finally, non-sampling error, for instance from imperfect reporting, may dominate statistical error leading to invalid estimates even for n ≈ M in some cases.

A Variance approximations
In order to find the smallest n that satisfies (5), we first need to compute the variance of the NSUM estimator in (4). Under the marginal degree model in (1), if we assume d i is fixed, then we have Although early NSUM methods similarly treated these degrees as fixed, Maltiel et al. [46] argues that they should be treated as random. We show that (10) is a good approximation of the variance even when d i is random. In particular, we show it is a conservative estimator, i.e. at least as big as the variance approximations under alternative degree models. To do so, we begin with a review of two methods for approximating the variance of a ratio of random variables.

C Simulations
We assess the relative error and coverage rates using the minimum sample size, by simulation. We employ a factorial design that varies the population size (M = 1000, 5000, 10000), the prevalence (q = .01, .03, . . . , .51), the nominal levels (α = .01, .05, .1, .2), and the underlying population graph model. We include i) an Erdős-Rényi network [56], G ∼ ER(M, p = 0.1), ii) an exponential random graph [59] with coefficients of −1 for edges and triangles, iii) a preferential attachment network [60] with power of 1.4 and M/20 new edges at each step, iv) a stochastic block model [61], and v) a small-world network [62] with a lattice of 50. We refer to these five random graph models as ER, ERGM, PA, SBM, and small-world, respectively. Each graph model has the same expected density around 10%, which allows us to isolate the effect of the graph topology and assess the robustness to network model mis-specification, i.e. how well our minimum sample size calculation works when the underlying population graph implies degree models that violate (1). Figure 3 shows the average relative error and coverage over 500 replicates. The columns represent the size of the population, M , and the rows represent the different (true) underlying population graph model. In the top plot, the average relative error is below the tolerated level ε for all values of M and q when the underlying graph model is ER, ERGM, and small-world. For low prevalence, PA and SBM have average relative errors that exceed the tolerance level, but this is mitigated as prevalence and population size increase. Results are similar in the bottom plot: the average coverage is conservative for ER, ERGM, and small-world across different nominal levels α, whereas it suffers for small populations with low prevalence for PA and SBM. As expected, the error bars are larger for larger values of α.
Although the minimum sample size works well for all of the graph models, we would like to better understand how the performance changes as the underlying population network gradually deviates away from an Erdős-Rényi network. To do so, we consider three models. First, we have a preferential attachment (PA) network in which M · (1 − δ) of the nodes are an Erdős-Rényi subgraph. Second, we have a two-block stochastic block model (SBM) with p · (1 + δ) on the diagonal and p · (1 − δ) off the diagonal. Finally, we have an exponential random graph model with a triangle coefficient of ±δ, which we denote ERGM (±). For all of these models, we vary δ from 0 to 1, and, as before, the average density for all of the networks is fixed at 10%. The results are shown in Figure 4. The error and coverage lie above and below, respectively, the tolerated levels only with extreme deviation from vertex-exchangeability, which further highlights the robustness of our estimator.