\section{Introduction}
Classical sampling requires a sampling frame, a list of individuals in the target population with a method to contact each individual (e.g. a phone number). For many populations, constructing a sampling frame is infeasible. Network driven sampling enables researchers to access populations of people, webpages, and proteins that are otherwise difficult to reach.  These techniques go by many names:  web crawling, Respondent-Driven Sampling, breadth-first search, snowball sampling, co-immunoprecipitation, and chromatin immunoprecipitation. In each application, the only way to reach the population of interest is by asking participants to refer friends.

Respondent-Driven Sampling (RDS) serves as a motivating example for this paper.   The Centers for Disease Control, the World Health Organization, and the Joint United Nations Programme on HIV/AIDS have invested in RDS to reach marginalized and hard-to-reach populations \cite{heckathorn1997respondent, WHO}. Each individual $i$ in the population has a corresponding feature $y_i$ (e.g. $y_i\in \{0,1\}$ and $y_i = 1$ if $i$ is HIV+).  Using only the sampled individuals, we wish to make inferences about the average value of $y_i$ across the entire population, denoted as $\mu$ (e.g. the proportion of the population that is HIV+). Extensive previous statistical research has proposed various estimators of $\mu$ which are approximately unbiased based upon various types of models for an RDS sample \cite{salganik2004sampling, volz2008probability, gile2011improved}. We note that in the papers cited above (except \cite{gile2011improved}), RDS is assumed to sample with replacement. Previous research has also explored the variance of these estimators \cite{goel2009respondent, treevar}. This paper studies the asymptotic distribution of statistics related to these estimators.

Results on asymptotic distributions for RDS are useful for two obvious reasons. First, they allow us to construct asymptotic confidence intervals for $\mu$. Second, they provide essential tools to test various statistical hypotheses. The only central limit theorem associated considered in the RDS literature studied the case when the tree indexed process reduces to a Markov chain \cite{goel2009respondent}; this presumes that each individual refers exactly one person. Previous research suggests that the number of referrals from each individual is fundamental in determining the variance of common estimators \cite{treevar}.  This paper establishes two central limit theorems in settings which allow for multiple referrals.

The main results apply to both the sample average and the Volz-Heckathorn estimator, which is an approximation of the inverse probability weighted estimator (cf Remark \ref{remark:transform}).  Because the inverse probability weighted (IPW) estimator  and its extensions are asymptotically unbiased, these estimators  are often preferred to the sample average.  However, sometimes survey weights are not needed and they only introduce additional variance to the estimator \cite{kenneth2016weights}.  This issue is particularly salient when sampling weights are highly heterogeneous, as is often the case in RDS.  Proposition \ref{prop:averageUnbiased} shows that if the outcomes $y_i$ are uncorrelated with the sampling weights, then the sample average is unbiased.  Theorem \ref{variancedifferenceTree} extends this result to RDS to show that the IPW estimator can have a larger variance than the sample average.   Taken together,  these results imply that the sample average can have a lower mean squared error (MSE) than the IPW estimator.  Section \ref{sec:example} introduces an estimator of the bias of the sample average.  The main results provide a path to test the null hypothesis that the bias is zero. This can be used to select between the sample average and the IPW estimator.  Section \ref{sec:addhealth} studies this routine with the AddHealth social network.

\section{Notation} \label{sec:notation}

\newtheorem{theorem}{Theorem}

\newtheorem{lemma}{Lemma}

\newtheorem{corollary}{Corollary}

\newtheorem{proposition}{Proposition}

\newtheorem{definition}{Definition}

\newtheorem{assumption}{Assumption}

\newtheorem{remark}{Remark}

Following \cite{goel2009respondent} and \cite{treevar}, the results below model the network sampling mechanism as a tree indexed Markov process on a graph.  There are many assumptions in this model which are incorrect in practice.  However, like the i.i.d assumption, it allows for tractable calculations.  In the simulations, we show that the theory derived from this model provides a good approximation for a more realistic sampling model.  \cite{lu2012sensitivity} studies the sensitivities of the estimators to this model.

Let $G=(V,E)$ be a finite, undirected, and simple graph with vertex set $V=\{1,...,N\}$ and edge set $E$. $V$ contains the individuals in the population and $E$ describes how they are related to one another.  As discussed in the introduction,  $y:V\rightarrow \mathbb{R}$ is a fixed real-valued function on the state space $V$; these are the node features that are measured  on the sampled nodes. The target of RDS is to estimate $\mu= N^{-1}\sum_{i=1}^{N}y(i)$.

If each sampled node referred exactly one friend, then the Markov sampling procedure would be a Markov chain.  Several classical central limit theorems exist for this model; see \cite{jones2004markov} for a review. The results herein allow for each sampled node to refer more than one node.  This is a Markov process indexed not by a chain, but rather by a tree.  Denote the referral tree as $\mathbb{T}$. Where the node set of $G$ indexes the population, the node set of $\mathbb{T}$ indexes the samples.  That is, we observe a subset of the individuals in $G$ with the sample $\{X_\tau\}_{\tau \in \mathbb{T}} \subset V$.  An edge $(\sigma, \tau)$ in the referral tree denotes that sampled individual $X_\sigma$ referred individual $X_\tau$ into the sample. Mathematically, $\mathbb{T}$ is a rooted tree--a connected graph with $n$ nodes, no cycles, and a vertex $0$ which indexes the seed node.  To simplify notation, $\sigma \in \mathbb{T}$ is used synonymously with $\sigma$ belonging to the vertex set of $\mathbb{T}$.

For each non-root node  $\tau\in \mathbb{T}$, denote $p(\tau) \in \mathbb{T}$ as the parent of $\tau$ (i.e. the node one step closer to the root).  This paper presumes that $\{X_\tau\}_{\tau \in \mathbb{T}}$ is a tree-indexed random walk on $G$, which was a model introduced by \cite{benjamini1994markov}.  This model generalizes a Markov chain on $G$; each transition $X_{p(\tau)} \rightarrow X_\tau$ is an independent and identically distributed Markov transition with transition matrix $P$. Following \cite{benjamini1994markov}, we will call this process a $(\mathbb{T},P)$-walk on $G$. Unless stated otherwise, it will be presumed throughout that the root node of the random walk $X_0$ is initialized from the equilibrium distribution of $P$. It follows that $X_{\sigma}$ has distribution $\pi$ for all $\sigma \in \mathbb{T}$.

Unless stated otherwise, the results in this paper allow for the transition matrix $P$ to be constructed from a weighted graph $G$. Let $w_{ij}$ be the weight of the edge $(i,j) \in E$; if $(i,j) \not \in E$, define $w_{ij} = 0$. If the graph is unweighted, then let $w_{ij} = 1$ for all $(i,j) \in E$. Define the degree of node $i$ as
$deg(i) = \sum_j w_{ij}$. If the graph is unweighted, then $deg(i)$ is the number of connections to node $i$.  Throughout this paper, the graph is undirected.  So, $w_{ij} = w_{ji}$ for all pairs $i,j$.
Given that $\{X_{p(\tau)} = i\}$, the probability of $\{X_\tau =j\}$ is proportional to $w_{ij}$;
\[P\left( X_\tau =j | X_{p(\tau)} = i \right) = \frac{w_{ij} }{ deg(i)}.\]
We use the term \textbf{simple random walk} for the Markov chain constructed on the unweighted graph (i.e. $w_{i,j} \in \{0,1\}$ for all $i,j$).  The simple random walk presumes that each participant selects a friend uniformly and independently at random from their list of friends.

In order to estimate $\mu$, we observe $y(X_\tau)$ for all $\tau \in \mathbb{T}$.  Because $G$ is undirected, $P$ is reversible and has stationary distribution $\pi$ with $\pi_i \propto deg(i)$ for all $i \in G$; this fact is helpful for creating an asymptotically unbiased estimator for $\mu$, particularly under the simple random walk assumption \cite{volz2008probability}.

\begin{remark} \label{remark:transform}
In general, the quantity of interest $\mu= N^{-1}\sum_{i=1}^{N}y(i)$ is not equal to $E_{\pi}(y)$. As such, the sample average of $y(X_\tau)$'s
is a biased estimator for $\mu$. With inverse probability weighting,  define a new function $y'(i)=y(i)(N\pi_i)^{-1}$ and the respective estimator
$$\hat{\mu}_{IPW}=\frac{1}{n}\sum_{\sigma \in \mathbb{T}}y'(X_{\sigma})=\frac{1}{n}\sum_{\sigma \in \mathbb{T}}\frac{y(X_{\sigma})}{N\pi_{X_{\sigma}}},$$
where $n=|\mathbb{T}|$ is the sample size. Then, $E_{\pi}(\hat\mu_{IPW})=E_{\pi}(y')=\mu$.  As such, the sample average of the $y'(X_\tau)$'s is an unbiased estimator of $\mu$.  Unfortunately, the values $\pi_i$ are unknown.
In practice, RDS participants are asked various questions to measure how many friends they have in $G$.  Under the simple random walk assumption, $\pi_i$ is proportional to the number of friends of $i$; this result also requires that the edges in $G$ are undirected, something that will be presumed throughout the paper.  Therefore the Volz-Heckathorn estimator

$$\hat{\mu}_{VH}=\sum_{\sigma \in \mathbb{T}}\frac{y(X_{\sigma})/deg(X_{\sigma})}{\sum_{\tau \in \mathbb{T}}1/{deg(X_{\tau})}}$$
is in essence a H\'ajek estimator based upon $deg(i)$ \cite{volz2008probability}.  Under the simple random walk assumption, this estimator provides an asymptotically unbiased estimator of $\mu$.
\end{remark}

For each node $\tau\in \mathbb{T}$, let $|\tau|$ be the distance of the node from the root; this is also called the ``wave'' of $\tau$. For every pair of node $\sigma, \tau \in \mathbb{T}$, define $d(\sigma, \tau)$ to be the distance between $\sigma$ and $\tau$ on $\mathbb{T}$ (as a graph). For each non-leaf node $\sigma \in \mathbb{T}$, let $\eta(\sigma)$ be the number of offspring of $\sigma$.  A tree is said to be an $m$-tree of height $h$ if $\eta(\sigma)=m$ for all $\sigma\in\mathbb{T}$ with $|\sigma|<h$ and $\eta(\sigma) = 0$ for all $|\sigma| = h$.  Here, both $m$ and $h$ are a natural numbers (i.e. $m,h\in \mathbb{N}$).  $\mathbb{T}$ is said to be Galton-Watson if $\eta(\sigma)$ are i.i.d random variables in $\mathbb{N}$. While the theorems below only study 2-trees; the computational experiments in Section \ref{sec:sim} suggest that the conclusions of the analytical results are highly robust to replacing the 2-tree with a Galton-Watson tree.

 \cite{levin2009markov} serves as this paper's key reference for Markov processes. Following the notation in that text, define $E_{\pi}(y)=\sum_{i=1}^{N}\pi_iy(i)$ and $var_{\pi}(y)=E_{\pi}(y-E_{\pi}(y))^2$ for the function $y$.

There are two primary concerns about the model and estimator used in the main results below.   First, the Markov model allows for resampling.  Second, the results below only apply to $m$-trees, not more general trees.  The simulations in Section \ref{sec:sim} suggest that the analytic results continue to hold under a more realistic setting that addresses both of these concerns.

\section{Main Results} \label{sec:main}

The threshold $m<\lambda_2^{-2}$ was previously identified in \cite{treevar} as being a critical threshold for the design effect of network driven sampling; beyond this threshold, the variance of the standard estimator does not decay at the standard rate. In other words,
$$var(\frac{1}{\sqrt{|\sigma\in \mathbb{T}:|\sigma|\leq h|}}\sum_{\sigma\in \mathbb{T}:|\sigma|\leq h}y(X_{\sigma}))\rightarrow \infty$$as $h\rightarrow \infty$. As such, using the traditional scaling, no central limit theorem holds above the critical threshold.
Because of this, the theorems focus on the  case $m<\lambda_2^{-2}$.
When $m> \lambda_2^{-2}$, the simulations in Section \ref{sec:sim} suggest that the central limit theorem does not hold for any scaling.

Theorem \ref{thm1} is a central limit theorem for an estimator constructed from the tree-indexed Markov chain. The theorem holds for any function $y$, any reversible transition matrix with second largest eigenvalue satisfying $|\lambda_2|\ne1$, and any  $m<\lambda_2^{-2}$.

\begin{theorem}
\label{thm1}
Suppose that $P$ is a reversible transition matrix with respect to the equilibrium distribution $\pi$, and that the eigenvalues of $P$ are $1=\lambda_1 > |\lambda_2| \geq... \geq |\lambda_N|$. Without loss of generality, suppose that $E_{\pi}(y)=0$. Define
$$Y_i=\frac{1}{\sqrt{m^i}}\sum_{\tau \in \mathbb{T}: |\tau|=i} y(X_{\tau}).$$If $\mathbb{T}$ is an $m$-tree with $m<\lambda_2^{-2}$, then $$\frac{1}{\sqrt{h}}\sum_{i=1}^{h} Y_i \rightarrow N(0, {\sigma}^2_0)$$in distribution,  where ${\sigma}^2_0=var_{\pi}((\sqrt{m}P-I)^{-1}y)-var_{\pi}(P(\sqrt{m}P-I)^{-1}y).$
\end{theorem}

The sequence of random variables considered in Theorem 1 are not exactly sample averages, but a reweighted form of sample average. Samples in the same wave are equally weighted, while samples from different waves are not. The following theorem provides theoretical guarantee on the distribution of sample average for a specific class of transition matrix and node feature.

\begin{theorem}
\label{thm2}
Let $\mathbb{T}$ be a $2-$tree. Without loss of generality, suppose that $E_{\pi}(y)=0$. Define $\hat \mu_h=\frac{1}{\sqrt{2}^h}\sum_{\sigma\in \mathbb{T}, |\sigma|\leq h}y(X_{\sigma})$. Suppose that

(c1) $E(\hat \mu_h^{2k+1})=0$ for all $h,k \in \mathbb{N}$;

(c2) for any function $f$ on $V$ satisfying $E_{\pi}f=0$, $||Pf||_{\infty}\leq |\lambda_2|||f||_{\infty}$;

(c3)$ |\lambda_2|<\frac{1}{\sqrt{2}}$;

then $${\hat \mu}_h \rightarrow N(0, {\sigma}^2_0)$$in distribution for some $\sigma_0^2$.

\end{theorem}

\begin{remark}

Condition (c1) is a technical condition on the symmetry of $\hat \mu_h$ that is necessary in the proof. The following proposition provides a sufficient condition for (c1).

\begin{proposition}
Suppose that $y$ is symmetric, i.e. for any $i\in V$ there exists $j$ such that $y(j)=-y(i)$. If $p(u,v)=P(y(X_{\sigma})=v|y(X_{p(\sigma)})=u)$ is well-defined and $p(u,v)=p(-u,-v)$ for all $u,v\in y(V)$, then condition (c1) is satisfied.
\end{proposition}

\begin{proof}
Under the conditions of the proposition, the distribution of $\hat \mu_h$ is symmetric with respect to 0. Thus $E(\hat \mu_h^{2k+1})=0$ for all $h,k \in \mathbb{N}$.
\end{proof}

Conditions (c2)-(c3) can be substituted by the following condition (c2'):

(c2') There exists $c<\frac{1}{\sqrt{2}}$ such that for any function $f$ on $V$ satisfying $E_{\pi}f=0$, $||Pf||_{\infty}\leq c||f||_{\infty}$.

Condition (c2') is weaker than (c2) and (c3) combined, but is stronger than (c3) alone. To see this, let $f$ be the eigenfunction of the second eigenvalue, and it follows that $ |\lambda_2|<\frac{1}{\sqrt{2}}.$ It can be easily seen that one necessary condition for (c2') is that $$\sum_j|P_{ij}-\pi_j|<\frac{1}{\sqrt{2}}$$ for all $i\in V$. In other words, all the rows of $P$ must be close to $\pi$. As previously discussed, condition (c3) is actually a necessary condition for the central limit theorem \cite{treevar}, in the sense that the variance of $\hat \mu_h$ tends to infinity if $ |\lambda_2|\geq\frac{1}{\sqrt{2}}.$
\end{remark}

For clarity in the exposition of the theorem and the proof, we have only proved the theorem for the 2-tree.  We believe that similar results are likely to hold for more general $m$-trees.

\subsection{Extension to the Volz-Heckathorn estimator}

When $P$ is restricted to be the transition matrix of the simple random walk on $G$,  the following corollary shows that Theorem \ref{thm2} can be extended to the Volz-Heckathorn estimator \cite{volz2008probability}.

Denote $\bar{d}=\frac{1}{N}\sum_{i \in V}deg(i)$ as the average node degree.
Following Remark \ref{remark:transform},  the IPW estimator contains $1/(N\pi_i)$ which is equal to $\bar{d}/deg(i)$.  The Volz-Heckathorn estimator first estimates $\bar{d}$ with  the harmonic mean of the observed degrees.  Because this harmonic mean converges to $\bar{d}$ in probability, the following corollary applies Slutsky's Theorem to give a central limit theorem for the Volz-Heckathorn estimator.

\begin{corollary}
\label{cor:vh}
Let $\mathbb{T}$ be a 2-tree. Suppose in particular that $P$ is the transition matrix of the simple random walk on $G$. Define a new node feature $y'(i)=y(i)/deg(i)$. Without loss of generality, suppose that $E_{\pi}y'=0$ (this is not equivalent to $E_{\pi}y=0$). Define
$$\hat\mu_{h,VH}=\hat\mu_{h}\hat{\bar{d}}=\frac{1}{\sqrt{2^h}}\sum_{\sigma\in \mathbb{T}, |\sigma|\leq h}y'(X_{\sigma})\hat{\bar d},$$where $$\hat{\bar{d}}=\frac{2^{h+1}-1}{\sum_{\sigma\in \mathbb{T}, |\sigma|\leq h}1/deg(X_\tau)}.$$ If the new node feature $y'$ and the transition matrix $P$ satisfy conditions (c1)-(c3) in Theorem \ref{thm2}, then
$$\hat\mu_{h, VH} \rightarrow N(0, {\sigma}^2_{0,VH})$$in distribution for some $\sigma_{0,VH}^2$.
\end{corollary}

\subsection{Illustrating the conditions with a blockmodel}\label{sec:block}

Consider $G$ as coming from a blockmodel with two blocks \cite{lorrain1971structural}.  In this blockmodel, each node $i$ is given a label $z(i) \in \{1,2\}$ and every edge weight $w_{i,j} = B_{z(i), z(j)}$ for some symmetric $2\times 2$ matrix $B$.  Suppose that $y_i = y_j$ if $z(i) = z(j)$.  This  model was previously studied in \cite{goel2009respondent} and it serves as an approximation to the Stochastic Blockmodel.

Given the structural equivalence of nodes within the same block, it is sufficient to study the transition matrix between blocks, $\mathscr{P} \in \mathbb{R}^{2 \times 2}$. If $\mathscr{P}$ is a symmetric matrix with entries $p_{11}=p_{22}=p$ and $p_{12}=p_{21}=1-p$ for some value $p$, then it can be easily verified that condition (c1) is satisfied.
Moreover, if $2p-1<\frac{1}{\sqrt{2}}$, then conditions (c2) and (c3) are also satisfied. Our theorem asserts that the Volz-Heckathorn estimator converges to the normal distribution in this model.

More generally, suppose that the nodes in the blockmodel for $G$ are equally balanced between $2K$ blocks with node features $\{y_1,-y_1,\dots,y_K,-y_K\}$ and that the transition matrix $p(u,v)=pI(u=v)+\frac{1-p}{2K-1}I(u\neq v)$. We can verify that all the conditions are satisfied as long as $\frac{1}{2K}<p<\frac{1}{2K}+\frac{1}{2\sqrt{2}}.$

\section{Comparing the variance of inverse probability weighting to the bias of the sample average} \label{sec:example}

An estimator with a small mean square error (i.e. $E(\hat \mu - \mu)^2$) has a small bias and a small variance. It is generally known that inverse probability weighting provides an unbiased estimator of $\mu$.  However, survey weights can also drastically inflate the variance of the estimator. This matter has been heavily studied by survey statisticians and substantial literature have devoted to the methodologies and issues regarding the use of sampling weights; see \cite{pfeffermann1996weights}, \cite{biemer2007weights}, \cite{valliant2013weights}, and \cite{kenneth2016weights} for a review.  To determine whether one should use sampling weights in RDS, this section gives a test statistic for the null hypothesis that the sample average is unbiased.  The results in the previous section suggest a confidence region for this test statistic.

 Denote $n = |\mathbb{T}|$ as the number of samples. The next results compare $\hat \mu_{IPW}$ to the sample average
$$\hat{\mu}=\frac{1}{n}\sum_{\tau \in \mathbb{T}}y(X_{\tau}).$$
Proposition \ref{variancedifference} and Theorem \ref{variancedifferenceTree} highlight the dangers of inverse probability weighting by showing that it can increase the variance.
Proposition \ref{variancedifference} studies the simplified case where the samples are i.i.d from the stationary distribution.  Following the proposition, Theorem \ref{variancedifferenceTree}  studies the more relevant setting of the $(\mathbb{T},P)$-walk on $G$.  To simplify the statements of Proposition \ref{variancedifference} and Theorem \ref{variancedifferenceTree} and their proofs, the node features $y(i)$ are presumed to be random variables. This condition could be removed with further technical conditions on the moments of $y: V\rightarrow\mathbb{R}$ and its relationship to $\pi$.

\begin{proposition}
\label{variancedifference}
Suppose that $X_1,...,X_n$ are sampled independently from the stationary distribution $\pi$ and that $y(1),..., y(N)$ are $N$ uncorrelated and identically distributed random variables with finite second moment $\mu_2$. Let $C_1=max_{1\leq i\leq N}N\pi_i$ and $var(\pi)=\frac{1}{N}\sum_{i=1}^{N}\pi_i^2-\frac{1}{N^2}$, then
\begin{equation}
\label{differenceEst}
var(\hat{\mu}_{IPW})-var(\hat{\mu})\geq\mu_2N(\frac{N}{nC_1^2}-1)var(\pi).
\end{equation}
Thus, as long as $N>C_1^2n$, which can be easily satisfied in practice,
$$var(\hat{\mu}_{IPW})>var(\hat{\mu}).$$
\end{proposition}

\begin{theorem}
\label{variancedifferenceTree}
Suppose that $\{X_\tau:\tau \in \mathbb{T}\}$ is a sample from the $(\mathbb{T},P)$-walk on $G$, and that $y(1),..., y(N)$ are $N$ uncorrelated and identically distributed random variables with finite second moment $\mu_2$. Assume that there exist constants $C_1, C_2$ and $C_3$ (not the same constants as in Proposition \ref{variancedifference}) such that $C_1N\leq d_i\leq C_2N$ for all $i$ and $N^2var(\pi)>C_3$. Then
\begin{equation}
\label{differenceEstTree}
var(\hat{\mu}_{IPW})-var(\hat{\mu})\geq \mu_2(\frac{N^2C_1^2}{nC_2^2}var(\pi)-\frac{C_2}{NC_1^2}),
\end{equation}
and there exists $C$ independent of $n$ such that $var(\hat{\mu}_{IPW})>var(\hat{\mu})$ as long as $N>Cn$.

\end{theorem}

Proposition \ref{variancedifference} shows that as $var(\pi)$ increases, the difference between the variance of $\hat \mu_{IPW}$ and $\hat \mu$ becomes larger.  Similarly, Theorem \ref{variancedifferenceTree} also shows that the difference between the variance of $\hat \mu_{IPW}$ and $\hat \mu$ increases as  $var(\pi)$ increases, given that the relative upper and lower bound of $d$ (i.e. $C_1$ and $C_2$) remain fixed.
Recall that when $P$ is the simple random walk, the probabilities $\pi_i$ are proportional to node degree. An extensive literature (e.g. \cite{strogatz2001exploring, clauset2009power}) has found  that  empirical networks have highly heterogeneous node degrees.
As such, Equation \ref{differenceEst} shows that the variance of $\hat{\mu}_{IPW}$ can be dramatically greater than the variance of $\hat{\mu}$. Moreover, both Proposition \ref{variancedifference} and Theorem \ref{variancedifferenceTree} suggest that the variance difference $var(\hat{\mu}_{IPW})-var(\hat{\mu})$ can be considerable if we sample only a small proportion of the whole population. This problem is particularly salient when the population is large.

The bias-variance tradeoff presents a dilemma between inverse probability weighting and the sample average.  This bias can be estimated.
For every $i\in V$, define a new node feature,
\begin{equation}
\label{newf}
y'(i)=y(i)(1-\frac{1}{N\pi_{i}})=y(i)(1-\frac{\bar{d}}{deg(i)}).
\end{equation}

\begin{proposition} \label{prop:averageUnbiased}
The mean of the new node feature satisfies
$$E_{\pi}(y')=E_{\pi}(y)-\mu,$$
which is the true bias of the sample average. Therefore, under the null hypothesis,
$$H_0: E_{\pi}(y')=0,$$
the sample average is an unbiased estimator. If $\pi$ and $y$ are uncorrelated (i.e.$\sum_{i\in V}\pi_iy(i)=\frac{1}{N}\sum_{i\in V}y(i)$), then $H_0$ is satisfied and the sample average is unbiased.
\end{proposition}

Under the conditions of Proposition \ref{variancedifference}, $\pi$ and $y$ satisfy the condition of Proposition \ref{prop:averageUnbiased} in expectation (i.e. they are uncorrelated in expectation).  Both of these conditions imply that the outcome is unrelated to the sampling weight (in some way).  Under such conditions, both estimators are unbiased.  If it is also true that $var(\pi)$ is large, then $\hat \mu$ has a smaller variance.  In this scenario,  $\hat \mu$ is preferable to $\hat \mu_{IPW}$ in terms of MSE.   However, if the sample average is biased, then we must compare the bias and variance of the two estimators.  Asymptotically, the variance of both estimators will vanish, while the bias stays constant.  So, for sufficiently large sample size, one should use $\hat \mu_{IPW}$.  For smaller sample sizes, the bias of the sample average could be small (relative to the difference in the variances).  In such settings, there will be a crossover point, a sample size at which $\hat \mu_{IPW}$ becomes preferable to $\hat \mu$.  To distinguish between these two cases, we want to test the null hypothesis that the sample average is unbiased, i.e. $E_{\pi}(y')=0$. Or, more generally, we want to provide a confidence region for the bias of the sample average.

If $\bar{d}$ is unknown, as is generally the case, we can estimate $\bar{d}$ by the harmonic mean \cite{salganik2004sampling}
$$\hat{\bar{d}}=\frac{n}{\sum_{\tau \in \mathbb{T}}1/deg(X_\tau)}.$$
Substituting $\bar{d}$ for $\hat{\bar{d}}$ in Equation \ref{newf} yields the new node feature based on the Volz-Heckathorn estimator \cite{volz2008probability}
$$y'_{VH}(i)=y(i)(1-\frac{\hat{\bar{d}}}{deg(i)}).$$
Similarly, define
\begin{equation}
\label{newf2}
\widehat{bias}=\frac{1}{n} \sum_{\sigma \in \mathbb{T}}y'_{VH}(X_{\sigma})=\frac{1}{n} \sum_{\sigma \in \mathbb{T}} y(X_\sigma)\left(1-\frac{\hat{\bar{d}}}{deg(X_\tau)}\right) = \hat \mu-\hat \mu_{VH},
\end{equation}
then $\widehat{bias} = \hat \mu-\hat \mu_{VH}$ is an asymptotically unbiased estimator for the bias of $\hat \mu$.  It serves as a test statistic for the null hypothesis $H_0: E_{\pi}(y')=0$.

The theorems above suggest that $\widehat{bias}$ converges to the normal distribution. The rejection region is then
$$
W=\{|\widehat{bias}|>1.96\frac{\hat{\sigma_0}}{\sqrt{n}}\}.
$$
where $\hat{\sigma_0^2}$ is an estimate of the variance.

\section{Estimating the variance} \label{sec:varhat}
For some node feature $\tilde y$ (e.g. HIV status $y$ or the $y'$ in Equation \eqref{newf} that motivate $\widehat{bias}$), let $\tilde \mu$ denote the sample average.  Denote $\sigma_{\tilde \mu}^2$ as $Var_{\mathbb{T}, P}(\tilde \mu)$, where the subscript $\mathbb{T}, P$ denotes that the data is collected via a $(\mathbb{T},P)$-walk on $G$. This subsection studies a simple plug-in estimator for $\sigma_{\tilde \mu}^2$.

The following function is essential to expressing $\sigma$ \cite{treevar}.

\begin{definition} \label{def:probgen}
Select two nodes $I, J$ uniformly at random from the tree $\mathbb{T}$.  Define the random variable $D = d(I,J)$ to be the graph distance in $\mathbb{T}$ between $I$ and $J$.  Define $\mathbb{G}$ as the probability generating function for $D$,
\[\mathbb{G}(z) = E( z^{D}).\]
\end{definition}
In practice, $\mathbb{T}$ is observed.  So, the function $\mathbb{G}$ can be computed.  In many studies there are multiple seed nodes.  In these cases, we suggest computing $d(I,J)$ on a tree which has an artificial root node that connects to all of the seeds; this root node could be imagined as an individual that is responsible for finding the seed nodes.  In this tree, two different seed nodes would be distance 2 apart.

Denote the autocorrelation at lag 1 of $\tilde y(X_\tau)$ as
\[R = \frac{Cov(\tilde y(X_{p(\tau)}), \tilde y(X_\tau))}{var_\pi(\tilde y)}.\]
Both $Cov(\tilde y(X_{p(\tau)}), \tilde y(X_\tau))$ and $var_\pi$ can be estimated with plug-in quantities.  Because the data has been sampled proportional to $\pi$,  the plug-in quantity for $var_\pi$ should not explicitly adjust for $\pi$.
\[\widehat{var_\pi(\tilde y)} = \frac{1}{n} \sum_{\tau \in \mathbb{T}} (\tilde y(X_\tau) - \hat \mu_{VH})^2.\]
Similarly,
\[\widehat{Cov(\tilde y(X_{p(\tau)}), \tilde y(X_\tau))} = \frac{1}{n-1} \sum_{\tau \in \mathbb{T}  \setminus 0} (\tilde y(X_{p(\tau)}) - \hat \mu_{VH})(\tilde y(X_\tau) - \hat \mu_{VH}),\]
where $\{\mathbb{T}  \setminus 0\}$ contains all nodes except the root node $0$ (because $p(0)$ does not exist).
Using these plug-in quantities, define $\hat R$.  Then, the estimator is
\[\hat \sigma_{\tilde \mu}^2 = \mathbb{G}(\hat R) \widehat{var_\pi(\tilde y)}.\]

A popular bootstrap technique for estimating $\hat \sigma_{\tilde \mu}^2$ resamples $y(X_\tau)$ as a Markov process (i.e. in addition to $X_\tau$ being a Markov process, the bootstrap procedure also assumes that $y(X_\tau)$ is Markov) \cite{salg}.  This model is akin to the blockmodel with two blocks in Section \ref{sec:block}.  The following assumption is weaker than this assumption.

\textbf{Assumption 1:} $\tilde y(i) = \mu + \sigma f(i)$, where $\mu, \sigma \in \mathbb{R}$ and  $f: V \rightarrow \mathbb{R}$ is an eigenfunction of $P$ with $var_\pi(f) = 1$.

\begin{proposition} \label{prop:equality}
Under Assumption 1,
\[\sigma_{\tilde \mu}^2 = \mathbb{G}(R) var_\pi(\tilde y).\]
\end{proposition}
While Assumption 1 is weaker than the previous assumption in \cite{salg}, the next proposition highlights the danger of this assumption.  It uses a different assumption which is a rather weak assumption.

\textbf{Assumption 2:} $\mathbb{G}$ is convex on $[\lambda_{\min},1]$, where  $\lambda_{\min}$ is the smallest eigenvalue of $P$.

Because $\mathbb{G}$ is a probability generating function, it is always convex on $[0,1]$.  As such, we on need to be worried about negative values.  Recall, that the central limit theorems above only hold when $|\lambda_{\min}| < 1/\sqrt{2} \approx .7$ (the smallest possible value for $\lambda_{\min}$ is $-1$).  Some simulated trees given in the appendix suggest that if $\mathbb{G}$ is not convex, it often fails in the neighborhood of $-1$.  As such, the assumption that $|\lambda_{\min}| < 1/\sqrt{2} \approx .7$ is likely to imply Assumption 2.  In practice, one observes the referral tree $\mathbb{T}$.  Thus, one can compute the second derivative of $\mathbb{G}$.
Eigenvalues of $P$ close to negative one arise in antithetic sampling, where adjacent samples are dissimilar.  For example, if the population in $G$ was heterosexuals and edges in $G$ represent sexual contact, then men would only refer women and vice versa.  In this case, $\lambda_{\min}$ would be exactly $-1$.  While easily imagined, such settings are not current practice for RDS.  As such, large an negative values are uncommon; $\lambda_{\min}$ is likely close to zero.

The following proposition follows from an application of Jensen's inequality.
\begin{proposition} \label{prop:auto}
Under Assumption 2,
\[\sigma_{\tilde \mu}^2 \ge \mathbb{G}(R) var_\pi(\tilde y).\]
\end{proposition}

Because Assumption 2 is not very restrictive, the inequality in Proposition \ref{prop:auto} highlights the danger in breaking Assumption 1 (and thus the Markov model in \cite{salg});  breaking Assumption 1 will lead to $\hat \sigma_{\tilde \mu}^2$ underestimating the variance.

\subsection{A bias adjusted estimator for $\mu$}
The test above also allows us to derive a more robust estimator of $\mu$. Define
$$\widehat{bias}=\frac{1}{n}\sum_{i=1}^{n}y'(X_{i}).$$
Then $\widehat{bias} = \hat \mu-\hat \mu_{IPW}$. Using the hypothesis test to choose between the sample average and inverse probability weighting is akin to hard thresholding the bias adjustment.  Define
$$\widehat{bias}_t = \left\{
\begin{array}{cc}
\widehat{bias} & \mbox{if reject $H_0$}  \\
0 & \mbox{otherwise}.\end{array}\right.$$
The final estimator of $\mu$ is then
$\hat \mu_{BA}=\hat \mu - \widehat{bias}_t$ (BA for bias adjustment).  This estimator is explored in Section \ref{sec:addhealth}.

\section{Numerical results}

\subsection{Simulation} \label{sec:sim}
In this section we illustrate the theoretical results on simulated data.
The simulations are performed on networks simulated from the Stochastic Blockmodel \cite{holland1983stochastic}. The four colors in Figure 1 correspond to four different networks that are simulated from four different Stochastic Blockmodels. Each of the four networks has N =5,000 nodes, equally balanced between group zero and group one. The probability of a connection between two nodes in different blocks is $r$ and the probability of connection between two nodes in the same block is $p$. To control the eigenvalues of the $5000\times5000$ transition matrix, consider the transition matrix between classes given by $\mathscr{P}=E(D)^{-1}E(A)$. The second eigenvalue of $\mathscr{P}$ is \cite{rohe2012sp}
$$ \lambda_2(\mathscr{P})=\frac{p-r}{p+r}$$ where expectations are under the Stochastic Blockmodel.  In our simulation, the second eigenvalue of the actual transition matrix is typically very close to $\lambda_2(\mathscr{P})$. We take $p+r=0.01$ in all four Stochastic Blockmodels so that the average degree is about 25. As such, $\lambda_2(\mathscr{P})$ is actually controlled by $p-r$.

For each of the four networks we carry out four different sampling designs. Let $\mathbb{T}$ be either a $2-$tree or a Galton-Watson tree with $E(\eta(\sigma))=2$. For the Galton-Watson tree, the distribution of $\eta(\sigma)$ is uniform on $\{1,2,3\}$. For each $\mathbb{T}$, we consider both with replacement sampling (i.e. the $(\mathbb{T},P)$-walk on $G$) and without replacement sampling (i.e. referrals are sampled uniformly from the friends that have not yet been sampled). Note that the conditions of Theorem \ref{thm2} may be violated when either the Galton-Watson tree or without-replacement sampling is used. We take the first 8 waves of $\mathbb{T}$ as our sample. As such, the sample size is roughly $N/10$.  For each social network and sampling design, we repeat the sampling process 2000 times and compute $\hat\mu=\frac{1}{n}\sum_{i=1}^{n}y(X_i)$ for each sample. The Quantile-Quantile (Q-Q) plot of $ \hat\mu$ is shown in the left panel of Figure \ref{fig:simulation}; note that the QQ plot centers and scales each distribution to have mean zero and standard deviation one. In addition, we repeat the above simulation for the Volz-Heckathorn estimator, and the QQ plot of $ \hat\mu_{VH}$ is shown in the right panel of Figure \ref{fig:simulation}.

\begin{figure}[h]
\centering
\begin{subfigure}[b]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{qqnorm_rev_SamAve.png}
\end{subfigure}
\begin{subfigure}[b]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{qqnorm_rev_VH.png}
\end{subfigure}
\caption{Q-Q plots of the sample average (left panel) and the Volz-Heckathorn estimator (right panel) for different social network and sampling designs. For each scenario we draw 2000 network driven samples of size $\approx$ 500 from a network containing 5,000 nodes. Here the threshold for $\lambda_2$ is $1/\sqrt{2} \approx 0.707$. For the two settings with $\lambda_2 < 1/\sqrt{2}$, the distributions appear normal.  However, for the two settings with $\lambda_2>1/\sqrt{2}$, the distributions do not appear normal.  Across all values of $\lambda_2$, there is no apparent difference between the four different designs (i.e. replacement sampling vs without replacement sampling and 2-tree vs Galton-Watson tree).}
\label{fig:simulation}
\end{figure}
\par

It is clear from Figure \ref{fig:simulation} that there are two patterns of distribution: when $\lambda_2<1/\sqrt{m}\approx 0.7$, i.e. $\lambda_2$=0.5 or 0.6, the Q-Q plots of $ \hat\mu$ and $ \hat\mu_{VH}$ approximately lie on the line $y=x$ for all sampling design;  when $\lambda_2>1/\sqrt{m}\approx 0.7$, i.e. $\lambda_2$=0.8 or 0.9, the Q-Q plot of $ \hat\mu$ and $ \hat\mu_{VH}$ departs from the line $y=x$. Taken together, Figure \ref{fig:simulation} suggests that the distribution of $ \hat\mu$ and $ \hat\mu_{VH}$ converges to Gaussian distribution if and only if $m<\lambda_2^{-2}$. Actually, the right panel of Figure \ref{fig:simulation} implies that there are two modes in the asymptotic distribution of $ \hat\mu$ and $ \hat\mu_{VH}$ when $m>\lambda_2^{-2}$. The relationship between the expectation of the offspring distribution and the second eigenvalue of the social network determines the asymptotic distribution of RDS estimators, regardless of the node feature, the particular structure of the tree or the way we handle replacement.

\subsection{Analysis of Adolescent Health data} \label{sec:addhealth}
To illustrate Theorem \ref{thm1} with the test statistic in Section 3, this section presents simulation results that use the Comm15 friendship network from the National Longitudinal Survey of Adolescent Health.  This simulation compares the MSE of $\hat \mu$  and $\hat \mu_{IPW}$ for two different node features $y$.  When $y$ is correlated with $\pi$, then $\hat \mu_{IPW}$ has a smaller MSE.  When $y$ is weakly correlated with $\pi$, then $\hat \mu$ has a smaller MSE.  For settings in which $\hat \mu_{IPW}$ clearly outperforms $\hat \mu$, the test statistic from Section 3 rejects the null hypothesis that the sample average is unbiased (i.e. $H_0: E_\pi \hat \mu = \mu$).

In the Comm15 network,  $N=1089$
students from two sister schools were asked to list up to 10 friends; these friends can be inside or outside of the school.  The students also supplied information including their gender, grade and race.
The analysis below studies two node covariates: gender (0/1) and total nominations of friends (integer between 0 and 10).  Before the simulation, the network was symmetrized (i.e. consider the new adjacency matrix $\tilde A=A+A^T$), yielding a network with average node degree $\bar{d}=8.06$.  Because the students were only allowed to list up to 10 friends, the standard deviation of the degrees is $4.7$.  This is drastically smaller than typical social networks.  However, even in this setting, the variance of $\pi$ is sufficiently large to illustrate the advantages of the sample average.

For both gender and the number of nominations, Table 1 displays (i) the correlation between $\pi$ and $y$, (ii) the bias of the sample average, and (iii) the crossover point.  Recall that the crossover point is the sample size at which the $\hat \mu_{IPW}$ has a smaller MSE than $\hat \mu$; this calculation is based upon the simulations described below.  The table shows that gender is weakly correlated with $\pi$.  As such, the sample average has a small bias and the crossover point is large.  Contrast this with the number of total nominations, which is highly correlated with $\pi$.  This makes the sample average clearly biased.  Because of this, it has a small crossover point.  These two examples illustrate a range of possibilities in terms of $cor(\pi, y)$.
\par
\begin{table}
\centering
\label{truebias}
\begin{tabular}{l|lll}\\
&$cor(\pi,y)$&Bias of sample average &Crossover point (sample size)\\
\hline
Gender&0.11&0.037&$>500$\\
Total nominations&0.54&1.1&20\\
\end{tabular}
\caption{Gender has a weak correlation with the sample weights.  As such, $\hat \mu$ has a small bias.  The crossover point shows that if the samples were drawn independently from the distribution $\pi$, then $\hat \mu$ has a smaller MSE when $n<500$.  Total nominations has a larger correlation and thus a larger bias.  When the sample size exceeds twenty, $\hat \mu_{IPW}$ outperforms the sample average.}
\end{table}

Before estimating the crossover points shown in Table 1, we first study the hypothesis test $H_0: E \hat \mu = \mu$ for both gender and total nominations.  To provide a benchmark, this simulation compares RDS to independent sampling.  Let $P$ be the transition matrix of the simple random walk on the network. The second largest eigenvalue of $P$ is $\lambda_2=0.93$. Let $\mathbb{T}$ be a sample from the Galton-Watson process with $E\eta(\sigma)=1.1<\lambda_2^{-2}$. For a node covariate $y$ (gender or nominations), let $y'$ be the node feature defined in Eq.\ref{newf2} in Section 3. Recall that $E_{\pi}(y')$ is the bias of the sample average.
 We consider the following methods of generating samples $Y_1, \dots, Y_n$ and computing or estimating the variance $\sigma^2$.
\begin{enumerate}
\item $Y_1,..., Y_n$ is an independent and identically distributed sample from the normal distribution $N(E_{\pi}(y'), var_{\pi}(y'))$
and $\hat{\sigma}^2=var_{\pi}(y').$  Here the variance is known.

\item $Y_i=y'(X_i)$ for all $i$, where $X_1,..., X_n$ is an independent and identically distributed sample from the equilibrium distribution of $P$, and $\hat{\sigma}^2=var_{\pi}(y').$ Here the variance is known.

\item $Y_i=y'(X_i)$ for all $i$, where $X_1,..., X_n$ is a sample from the $(\mathbb{T},P)$-walk on $G$,
and $\hat{\sigma}^2$  is the true variance that is only computable in a simulation,  $var(\frac{1}{\sqrt{n}}\sum_{i=1}^{n}Y_i).$

\item $Y_i=y'(X_i)$ for all $i$, where $X_1,..., X_n$ is a sample from the $(\mathbb{T},P)$-walk on $G$, and $\hat{\sigma}^2=\widehat{var_{\pi}(y')}\mathbb{G}(\hat R)$, the estimator discussed in Section \ref{sec:varhat}.
\end{enumerate}

For a sample of size $n$, let the rejection region be$$W=\{|\frac{1}{\sqrt{n}\hat{\sigma}}\sum_{i=1}^{n}Y_i|>1.96\},$$with $Y_i$ and $\hat{\sigma}$ to be defined above.  Here,  the null hypothesis is rejected at $\alpha=0.05$.   For each scenario, Figure \ref{fig:power} plots the power of our test $pr(W)$ as a function of sample size.
The power under scenario (1) can be calculated exactly and serves as a benchmark (black line). The power under scenario (2)-(4) is calculated by taking 1000 independent samples and counting the number of samples that fall in $W$ (red, blue, yellow lines respectively).

Because scenario (4) underestimates the true variance, this technique is conservative in rejecting $H_0$ and adopting $\hat \mu_{IPW}$.  For gender, none of the scenarios quickly reject the null hypothesis. Compare this to the number of total nominations.  Here, $H_0$ is rejected even for small sample sizes.

\begin{figure}
\centering
\begin{subfigure}[b]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{powersex.pdf}
\subcaption{Gender}
\end{subfigure}
\begin{subfigure}[b]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{powernom.pdf}
\subcaption{Total nominations}
\end{subfigure}
\caption{Power of test as a function of sample size for two node features (a) gender and (b) total nominations of friends. The black, red, blue and yellow lines are the power under scenarios 1-4 respectively. }
\label{fig:power}
\end{figure}

The final figure plots the mean square error of $\hat \mu, \hat \mu_{IPW},$ and $\hat \mu_{BA}$; this last estimator is the bias adjusted estimator from Section \ref{sec:example}.  This simulation uses scenario  (4), the most realistic of the previous scenarios.  After drawing the sample, compute the following (for both gender and total nominations)
\begin{enumerate}
\item The inverse probability weighted estimator $$\hat{\mu}_{IPW}=\frac{1}{n}\sum_{i=1}^{n}\frac{y(X_{i})}{N\pi_{X_{i}}}=\frac{1}{n}\sum_{i=1}^{n}\frac{y(X_{i})\bar{d}}{deg(X_i)}.$$
\item The sample average $\hat{\mu}=\frac{1}{n}\sum_{i=1}^{n}y(X_{i}).$
\item The bias adjusted estimator $$\hat{\mu}_{BA}= \left\{
\begin{array}{cc}
\hat{\mu}_{IPW} & \mbox{if $\{X_i\}_{1\leq i \leq n} \in W,$}  \\
\hat{\mu} & \mbox{if $\{X_i\}_{1\leq i \leq n} \notin W,$}
\end{array}
\right.$$
introduced in Section 3.
\end{enumerate}

Figure \ref{fig:mse} shows that for gender, the true bias of the sample average is small.  As such, the MSE of $\hat{\mu}$ (solid) is always smaller than that of $\hat{\mu}_{IPW}$ (dotted) (for sample sizes  $n<500$). For total nominations, the bias is much larger.  So, when $n>20$, the MSE of  $\hat{\mu}$ is larger than the MSE of $\hat \mu_{IPW}$. The MSE of the bias adjusted estimator $\hat{\mu}_{BA}$ (longdash) lies between that of $\hat{\mu}$ and $\hat{\mu}_{IPW}$.  In particular, when $\hat \mu_{IPW}$ drastically outperforms $\hat \mu$ (i.e. on the right of panel b), the null hypothesis is typically rejected and $\hat \mu_{BA}$ performs similarly to $\hat{\mu}_{IPW}$.

\begin{figure}
\centering
\begin{subfigure}[b]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{msesex.pdf}
\subcaption{Gender}
\end{subfigure}
\begin{subfigure}[b]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{msenom.pdf}
\subcaption{Total nominations}
\end{subfigure}
\caption{The mean square error of $\hat{\mu}$ (solid), $\hat{\mu}_{IPW}$ (dotted), and $\hat{\mu}_{BA}$ (longdash) for gender and total nominations.}
\label{fig:mse}
\end{figure}

\section{Discussion}

A recent review of the RDS literature counted over 460 studies which used RDS \cite{white2015strengthening}.  Many of these studies seek to estimate the prevalence of HIV or other infectious diseases; for these studies, a point estimate of the prevalence is insufficient.  These studies have used confidence intervals constructed from bootstrap procedures and from estimates of the standard error \cite{RDSpackage}.  These standard error intervals implicitly rely on a central limit theorem and this paper provides a partial justification for such techniques, so long as $m \le 1/\lambda_2^2$.  This paper makes a first step at studying the distributional properties of two simple estimators in this regime.

Figure \ref{fig:simulation} suggests that if $m$ is larger than $1/\lambda_2^2$, then the simple estimators ($\hat \mu$ and $\hat \mu_{VH}$) are no longer normally distributed. Interestingly, under the simulation setting where the estimators are no longer normally distributed, the Q-Q plots are flatter than the line $x=y$.  This indicates that a confidence interval constructed from the standard errors would be conservative; a nominally  90\% confidence interval would cover $\mu$ more than 90\% of the time.  As such, a properly constructed interval should be narrower than the interval constructed from the standard error. If one pursues this path, then care must be taken in estimating the standard errors.  For example, a bootstrap procedure proposed in \cite{salg} has become very popular.  However, for reasons beyond the inequality in Proposition \ref{prop:auto}, this bootstrap procedure drastically underestimates the actual standard errors \cite{goel2010assessing, treevar}.

There are many reasons to suspect the construction of the sampling weights in RDS studies.  At the most basic level, the justification for
\[\{\mbox{selection probability for node $i$}\} \propto deg(i)
\]
comes from a Markov model which has several problematic pieces (e.g. replacement sampling, uniform selection of friends, referral process has reached equilibrium, and all network relationships are reciprocated). While these assumptions are all troublesome, they are merely sufficient conditions.  It is conceivable that $deg(i)$ is still an adequate approximation of the selection probabilities (up to scaling) even when the assumptions do not hold.  Perhaps the most difficult problem is that $deg(X_i)$ is estimated via self-report.  Taken together, there are many reasons to doubt the sampling weights.   In a related context, the third section of the paper discusses the bias-variance tradeoff between $\hat \mu$ and $\hat \mu_{IPW}$.
The results in Proposition \ref{variancedifference} and Theorem \ref{variancedifferenceTree} presume that the sampling weights are known exactly.  However, given that the presumed model has several deficiencies, the stationary distribution of the (presumed) Markov process does not necessarily reveal the actual sampling probabilities.  As such,  $\hat \mu_{IPW}$ (and by extension $\hat \mu_{VH}$) are constructed with incorrect and noisy measurements of the sampling probabilities. This will likely make the estimator biased and more variable.  Because of this, in practice we should be less inclined towards the weighted estimator  (i.e. $\hat \mu_{VH}$) than the proposed estimator $\hat \mu_{BA}$ suggests.  Section \ref{sec:example} and the data analysis with the AddHealth network suggest that the sample average is perhaps less biased than was previously considered.  While there are certainly situations where bias corrected estimators should be used, it also seems sensible to first estimate the bias; when the bias is large, this is a relatively easy task.

The theorems in this paper do not apply to general trees, only to m-trees.
If $\mathbb{T}$ is a Galton-Watson tree with $E(\eta(\sigma))<\lambda_2^{-2}$,
then the simulations support the following conjecture:
$$\frac{1}{\sqrt{n}}\sum_{\sigma \in \mathbb{T}}(y(X_{\sigma})-E_{\pi}(y))\rightarrow N(0,\sigma^2),$$
where $\sigma^2$ could be computed from the results in \cite{treevar}.
To prove this result requires a more careful study of the structure of $\{X_{\sigma}\}_{\sigma \in \mathbb{T}}$. We leave this problem to future investigation.

\section*{Acknowledgement}

This material is based upon work supported in part by the U. S. Army Research Office under grant number W911NF1510423 and the National Science Foundation under grant number DMS-1309998.
We thank Zoe Russek for helpful comments.


\section{Introduction}
\label{sec:introduction}

The past years have brought impressive advancements in the field of dense environment mapping, fueled by the advent of RGB-D cameras and ever more powerful processors, including GPUs. Applications of (near-)real-time 3D dense mapping systems are vast, ranging from digital twins and Augmented/Virtual Reality to mobile robotics.
Recent technological advances are inciting the use of mobile robots for exploration and monitoring tasks. Their growing versatility and autonomy offer safe, cost-effective solutions in a wide range of applications, including aerial surveillance, infrastructure inspection, and search and rescue \cite{Nex2014}. However, to fully exploit their potential, a key task is enabling light-weight platforms to operate autonomously in unknown, unstructured environments with limited on-board computational resources. Map representations are thus required that can accommodate both high-fidelity reconstructions of the environment as well as perform fast online planning.

\begin{figure}[t]
    \centering
    \includegraphics[trim={0.1cm 0.1cm 0.1cm 0.9cm},clip, width=0.985\columnwidth]{images/cow_and_lady_mof_w_traj.png}
    \caption{The main goal of our system is to provide a navigable 3D occupancy map with a defined notion of observed free space in small to large scale scenarios, using adaptive resolution to constrain memory consumption. The figure shows the output of our mapping pipeline for the \textit{Cow and Lady} RGB-D dataset \cite{Oleynikova2017} alongside a planned trajectory (red). The chosen voxel resolutions for free space encoding are shown for a map slice.}
    \label{fig:cover}
\end{figure}

There are several efficient mapping methods for motion planning that rely on 3D volumetric representations. A common strategy is to use probabilistic occupancy maps using octree structures for quick access \cite{Hornung2013,Vespa2018}. More recently, signed-distance-based frameworks \cite{Oleynikova2017,Han2019,Vespa2019} have become popular as they allow fast map query operations in online settings. The main drawback of previous approaches is that their computational performance degrades drastically with the discretisation of the environment, since they operate on map data in the same way regardless of the occupancy status and geometry of the underlying space. As a result, these methods are only suitable for scenarios requiring coarse reconstructions or navigating in areas with relatively large obstacles. In contrast, our work addresses the challenge of trading off mapping accuracy  against computational efficiency for planning in online, on-board robotic applications that require \textit{both}.

In this paper, we introduce a volumetric adaptive-resolution \textit{dense} mapping framework that supports multi-resolution queries and data integration using occupancy mapping \cite{Hornung2013,Elfes1989,Thrun2003}. Contrary to methods based on signed distance functions, we continuously maintain a high resolution 3D octree representation of observed  occupied and \textit{free} space in real-time.

Our key insight is to recognise the lack of a concise method for defining required resolution in the context of occupancy mapping, with few approaches tackling this problem by extending single resolution approaches with ad-hoc heuristics \cite{Vespa2018}.
As a result, we designed a novel integration algorithm that selects resolution by constraining the induced sampling error in the observed occupancy, splitting an octree in a coarse-to-fine fashion until a desired accuracy is reached. Central to this idea is the introduction of a multi-scale max-min pooling of the input depth image which enables real-time operation by providing a conservative indication of measured depth variation in any given volume with only a few queries.

To further enhance performance, we \edit{modified} the data structure of \cite{Vespa2019} which uses mip-mapped voxel blocks, and carefully designed a new scale selection and data propagation scheme between levels. This allowed us to increase computational and memory efficiency without introducing reconstruction artefacts.

While our method focuses on RGB-D mapping, it is flexible to different sensor modalities. This is shown by evaluating our system in a wide range of datasets, from synthetic to large scale LIDAR, showing significant improvements in reconstruction accuracy, runtime performance, and planning performance against state-of-the-art approaches.
In summary, the main contributions of this paper are:

\begin{enumerate}
    \item A dense volumetric multi-resolution system, \edit{comprising a data structure, fusion method and sensor models which together enable real-time online probabilistic occupancy mapping and accurate surface reconstruction, by consistently} representing free and occupied space to fine resolutions where needed; we will release our reference implementation open-source upon acceptance of this work.
    \item A novel fast map-to-image allocation \edit{algorithm}  and integration method, that seamlessly adapts the map to different scene scales and sensor modalities
    \item A comprehensive evaluation with respect to the state-of-the-art revealing vast improvements in the trade-offs of mapping accuracy, speed, memory consumption, tracking accuracy, and planning performance.
\end{enumerate}

\section{Related Work}
\label{sec:related_work}

A large body of literature addresses the problem of obtaining a dense 3D representation of the world. In this section, we overview recent work, focusing on volumetric reconstruction methods suitable for real-time robotic applications running on constrained hardware. This leaves aside most batch integration methods, where a map is only available for planning at the end of the mapping run; note that most newer deep learning based methods fall in this category.

A major milestone in online RGB-D 3D reconstruction systems is KinectFusion \cite{Newcombe2011}, which enables dense volumetric modelling in real-time at sub-centimetre resolutions. However, it is limited to small, bounded environments, as the mapping is locked to a fixed volume with a pre-defined voxel resolution, and requires GPGPU processing to achieve real-time performance. To improve scalability, several extensions to the original algorithm have been proposed. One possibility is to use moving fixed-size sliding volumes \cite{Whelan2012,Usenko2017} to achieve mapping in a dynamically growing space. Another strategy is to exploit memory-efficient data structures, such as octree-based voxel grids \cite{Vespa2018,Zeng2013,Steinbrucker2014} or hash tables \cite{Niessner2013,Klingensmith2015}, for quicker spatial indexing. More recently, deep learning methods tackling this problem in an incremental fashion are also being introduced \cite{Weder2020}. Despite impressive progress, most 3D mapping research has targeted the application of surface reconstruction, which aim to produce a high-quality mesh/point-cloud of a scene. From a navigation perspective, the concept of observed free space is equally or more important than surface accuracy. Unfortunately, most of these methods model free space only near the surface boundaries and do not generally distinguish between free and unvisited areas in initially unknown environments. Our work provides an explicit distinction between the two as necessary for robotic planning, exploration, and collision avoidance.

In the context of navigation, \ac{ESDF}-based mapping methods are commonly used for motion planning tasks as they provide distance information for trajectory optimisation strategies. Recently, significant work has been done on incrementally building \ac{ESDF} maps for planning in 3D using aerial robots, including the \textit{voxblox} \cite{Oleynikova2017} and \textit{FIESTA} \cite{Han2019} frameworks, which construct \ac{ESDF} maps from \ac{TSDF} maps and occupancy maps, respectively. However, as these methods are designed for fast on-board collision checking, they rely on coarsely disretised environments with voxel grid resolutions on the order of $\sim 20$\,cm magnitude. In contrast, our approach is also motivated by applications like close-up inspection \cite{Stent2015}, which require detailed scene reconstructions.

An alternative representation for planning is the occupancy map \cite{Elfes1989,Thrun2003}. In 3D, OctoMap \cite{Hornung2013} is a popular framework that uses hierarchical octrees to track occupancy probabilities as sensor data is received. Similar to the original work of \cite{Elfes1989}, it uses an inverse sensor model that efficiently approximates the posterior using an additive log-odds update equation, which resembles the \ac{TSDF} update procedure \cite{Newcombe2011}.

However, while OctoMap works well with sparse LIDAR data, its performance degrades significantly as map resolution increases, as well as with noisier sensors. Interestingly, a very recent contribution shows improvements over OctoMap in terms of memory and run time by adaptively downsampling the pointcloud and integrating free space at lower resolutions  \cite{Duberg2020}, highlighting the importance of this topic. While this method uses a set of distance-based rules to decide the integration resolution (similar to \cite{Vespa2018}), leading in the fastest setups to non-conservative assignments of free space, our work tackles this problem by rigorously assessing the probabilistic (inverse) measurement model, introducing an approach for choosing a sampling resolution that ensures these errors do not happen, while also improving run time performance.

Closest to our work, \cite{Vespa2018} proposed an efficient pipeline with an octree-based implementation for reconstruction and planning. Their approach supports either \ac{TSDF}-based or occupancy mapping using the spline inverse sensor model of \cite{Loop2016}. However, the use of multi-resolution is very basic and multiple assumptions limit its applicability to planning.

Subsequent work \cite{Vespa2019} extended this system to handle data integration with varying levels of detail and rendering at multiple resolution scales using \ac{TSDF} maps, but limited to surface reconstruction. Our method draws inspiration from this approach in terms of data structure and propagation; however, our focus is on volumetric occupancy-based representations for planning and space understanding, where the goal is to probabilistically classify all observed space into occupied, free, or unknown at high resolutions, while also providing a high quality (surface) reconstruction of the environment.

\begin{figure}[htb]
    \centering
    \includegraphics[width=\columnwidth]{images/pipeline_overview_s.jpeg}
    \caption{Overview of our system: The different stages of the mapping pipeline are shown in grey, while the blue boxes show the steps in the \textit{allocation and updating} procedure. The flow of information is illustrated by the arrows. The allocation and updating stages modify the map, while the rendering and planning stages utilise the map information.}
    \label{fig:block_diagram}
\end{figure}

\begin{figure}[htb]
    \centering
    \includegraphics[width=\columnwidth]{images/data_structure.png}
    \caption{\edit{Overview of the data structure for a hypothetical 2D case. Data is represented in a two tier octree having voxel blocks in the lower levels. Depending on the distance based integration scale $s_c$ voxel blocks containing data up to different resolutions are allocated, resulting in important memory and time savings for cases where higher resolution is not needed. Note that in the given example the integration scale $s_c$ for blocks only containing free and unknown space has a lower bound of $s_c > 1$} (Section \ref{section:Fusion}).}
    \label{fig:quadtree}
\end{figure}

\section{Multi-Resolution Occupancy Mapping}
\label{sec:mapping_approach}

Our library takes as input depth information and poses, incrementally computing a map which can be queried at any time for path planning, meshing, and rendering (see Fig. ~\ref{fig:block_diagram}). We also provide an \ac{ICP} module that can be switched on to obtain a full \ac{SLAM} system in the spirit of \cite{Newcombe2011}, as shown in Section~\ref{subsec:tracking}.

\edit{In order to represent an occupancy efficiently using adaptive resolution we use an octree where, similar to \cite{Vespa2018}, the last levels consist of densely allocated voxel blocks aggregating up to $8 \times 8 \times 8$ voxels at the finest scale. This two tier memory structure leverages flexibility in choosing resolution at the higher (octree) levels with efficient access at lower (voxel block) level. Taking inspiration from \cite{Vespa2019}, each voxel block stores a pyramid representation of itself enabling fast occupancy updates at different resolutions. However, unlike \cite{Vespa2019}, we save memory by not keeping all mipmap levels and only allocating data in each block down to a single dynamically changing integration scale $s_c$, in other words our design has different voxel block types which are changed dynamically depending on the needed integration scale. More importantly, we augment this method by also allowing data to be stored at node level when the voxel block resolution is finer than needed. A representation of this structure can be seen in Fig.~\ref{fig:quadtree} for a hypothetical 2D case. }

For a given point, the relevant occupancy information is maintained only at the lowest allocated voxel that contains it. Similar to \cite{Hornung2013}, upper non-leaf nodes store a max pooling of the children occupancy, enabling fast conservative queries of any given size. In addition to the max occupancy, we keep a Boolean state indicating whether unknown data is present in the children. This allows us to disambiguate a node as being partially or fully unobserved. In our system this pooling, or data up-propagation, is computed in each integration step, making it available for online planning at any given time.

\subsection{Notation}
\label{sec:notation}
We denote $n$-dimensional vectors with lower-case, bold letters, e.g.\ $\mathbf{x} \in \mathbb{R}^n$.  Also, we denote the coordinate frame in which vectors are expressed with left subscripts, e.g.\ $_C\mathbf{x}$. We employ a World frame $\{W\}$ and the Camera frame $\{C\}$.
Euclidean transformations from coordinate frame $\{C\}$ to $\{W\}$ are denoted as $\mathbf{T}_{WC} \in \ensuremath{\mathrm{SE}(3)}\xspace$.
We denote matrices with upper-case bold letters, e.g.\ $\mathbf{D} \in \mathbb{R}^{n \times m}$.

\subsection{Occupancy Map Fusion}
\label{subsec:occupancy_map}

Given a depth image $\mathbf{D}_k \in \mathbb{R}^{H \times W}$ and camera pose $\mathbf{T}_{WC_k}$ at time step $k$,
the probability that a point $_W\mathbf{p}$ in 3D space is occupied is assumed to depend on the distance to the camera and the corresponding depth measurement along the ray from the camera centre $_W\mathbf{c}$ to $_W\mathbf{p}$.
Given the depth measurement $z$ from the projection of point $_W\mathbf{p}$ into the camera, we represent the occupancy probabilities of one depth image  in 3D:
\begin{align}
    P_\mathrm{occ}\big(_W\mathbf{p} \, | \, \mathbf{D}_k, \mathbf{T}_{WC_k}\big)
    = P_\mathrm{occ} \big(_W\mathbf{p} \, | \, z
    = \mathbf{D}_k \big[\pi(\mathbf{T}_{WC_k}^{-1} {_W\mathbf{p}})\big] \big) \,,
    \label{ec:p_occ_p}
\end{align}

which corresponds to the inverse sensor model \cite{Thrun2003}, a function of the depth along the ray. For brevity, it is referred to as $P_{\mathrm{occ}}(_W\mathbf{p}|z)$ in the following descriptions.
An alternative way of representing the occupancy probability is using log-odds, which allows for Bayesian updates to be additive as:
\begin{align}
    l_k (_W\mathbf{p}) &= \log \frac{P_{\mathrm{occ}}(_W\mathbf{p}|z)}{1 - P_{\mathrm{occ}}(_W\mathbf{p}|z)} \, ,
    \label{ec:log_odds_updt_og1} \\
    L_{k} (_W\mathbf{p}) &= L_{k-1} (_W\mathbf{p}) + l_k (_W\mathbf{p}) \, .
    \label{ec:log_odds_updt_og2}
\end{align}

In contrast to previous work, we do not accumulate the log-odds in a single sum, but instead use a weighted mean $\bar{L}_{k}(_W\mathbf{p})$, with weight $w_k$, similar to how it is done in \cite{Newcombe2011} \edit{providing additional information about the number of integrations}. Thus the mean log-odds is updated as:
\begin{align}
    \bar{L}_{k}(_W\mathbf{p}) &= \frac{\bar{L}_{k-1}(_W\mathbf{p}) \ w_{k-1} + l_{k}(_W\mathbf{p})}{w_{k-1} + 1} \, ,
    \label{eq:update_mean_log}\\
    w_k &= \min\{w_{k-1} + 1, w_{\max}\},
\end{align}
while the accumulated log-odds can be preserved:
\begin{align}
        L_{k}(_W\mathbf{p}) &= \bar{L}_{k}(_W\mathbf{p}) \ w_k \,.
    \label{ec:log_odds_updt}
\end{align}
By clamping the weight $w_k$ below a threshold $w_{\max}$,
the influence of outliers and dynamic objects is mitigated.  \edit{Moreover, using a maximum weight $w_{\max}$ rather than an occupancy threshold prevents the occupancy field at the surface from converging to a step function and does not require the use of a time based windowed updating step as in \cite{Vespa2018}}.

\subsection{Inverse Sensor Model}
For fast computations, our inverse sensor model is a piece-wise linear function based on \cite{Loop2016} and illustrated in Fig. \ref{fig:sensor-model} (a) operating directly in log-odds space.
Similarly to \cite{Loop2016}, we use a model where the measured surface position matches a log-odds value of zero.

We model  depth uncertainty $\sigma$ as a function of measured depth $z$, assuming it to be linearly or quadratically growing depending on the sensor type (see Fig. \ref{fig:sensor-model} (b)): quadratic for RGB-D and linear for LIDAR or synthetic (perfect) depth cameras.
We relax the assumption of quadratic relation made in \cite{Loop2016} between the surface thickness $\tau(z) \propto z^2$  with a linear model $\tau(z) \propto z$ bounded by a minimum and maximum surface thickness $\tau_{\min}$ and $\tau_{\max}$, to avoid overgrowing of distant objects.

\begin{figure}[htb!]
    \centering
    \includegraphics[ width=0.98\columnwidth]{images/sigma_prob_figure.pdf}
    \caption{(a) Inverse sensor model for two measurements (1m, 5m) expressed as a function of the difference  $d_r$ from a query point  to the measured surface along the ray. Log-odd values in front of the surface are clipped at $l_{\min}$ reached at $\mu = 3 \sigma$ and grow linearly up to half the surface thickness $\tau(z)$.
    (b) Distance-dependent growth of two sensor uncertainty models (linear and quadratic) within the minimum and maximum sensor range $z_{\text{np}}$ and $z_{\text{fp}}$ and sensor uncertainty $\sigma_{\min}$ and $\sigma_{\max}$.}
    \label{fig:sensor-model}
\end{figure}

\subsection{Adaptive-Resolution Volume Allocation}
\label{subsec:map_to_cam}

The data structure is interpreted as a non-uniform partition of a continuous occupancy 3D scalar field \cite{Vespa2018}. Consequently we do not assign any probabilistic meaning to the size of the voxel storing a particular value and instead aim at choosing a partition of the tree which can represent the underlying continuous function up to a certain accuracy.

\begin{figure}[htb]
    \centering
    \includegraphics[trim={1.7cm 0 9.7cm 0},clip, width=0.49\columnwidth]{images/of_allocation_s.jpeg}
    \includegraphics[trim={1.7cm 0 9.7cm 0},clip, width=0.49\columnwidth]{images/mof_allocation_s.jpeg}
    \caption{\edit{Comparison of free space volume allocation in OFusion \cite{Vespa2018} (\textbf{left}) and our new adaptive-resolution strategy (\textbf{right}) in an environment with a wall and vertical pole. Blue corresponds to free space and white lines indicate allocated voxels on a map slice. While OFusion ignores occupancy variations inside a voxel's volume, leading to erroneous assumptions of free space behind the pole, our method naturally integrates the volume at the appropriate scale, allocating obstacles and boundaries to unknown space at fine resolution, while representing free space at the coarsest possible level.}}
    \label{fig:motivation}
\end{figure}

Choosing this partition -on the fly- in a volumetric space is not a trivial task. Methods like \textit{OctoMap} \cite{Hornung2013} use a ray-casting scheme to allocate densely the observed space, simplifying resolution in a later stage called tree pruning. Newer methods like \textit{OFusion} \cite{Vespa2018} and \textit{UFOMap} \cite{Duberg2020} mitigate the need for dense allocation by using a set of heuristics to choose the needed resolution during the allocation step. The main problem with these approaches is illustrated in Fig.~\ref{fig:motivation}. The fact that resolution is chosen as part of the ray-casting and mainly as function of distance tends to ignore changes in occupancy that happen because of depth changes between pixels, which often require high resolution allocation to be accurately captured, leading to parts of space being erroneously labeled as free. This is particularly important in occlusions caused by thin objects and frustum boundaries.

To solve this problem we take a radically different approach, discarding the raycasting and using a so called  `map-to-camera' allocation and updating process, thereby following an `as coarse as possible, as fine as required' mapping scheme.
Given a new depth image  $\mathbf{D}_k$, we start from the root of the octree analysing each node recursively in order to decide whether the variation of occupancy log-odds inside the node meets a bounding criterion:
\begin{equation}
    \max{|l_k(_W\mathbf{p}_i) - l_k(_W\mathbf{p}_j)|} < \epsilon
    \label{eq:split_crit}
\end{equation}
for every $_W\mathbf{p}_i, \, _W\mathbf{p}_j$ in the node volume. This criterion, which has been used for 3D data compression on an octree \cite{Knoll2006}, \edit{bounds the occupancy error from a sampling perspective, a desirable feature for safe navigation maps.}
If it is met, we update the node at the given scale;
otherwise, it is split into its eight children, and the process is recursively repeated until \eqref{eq:split_crit} is satisfied or voxel block level is reached.

\edit{
Evaluating \eqref{eq:split_crit} naively would require a high resolution sampling of the model in the node's volume, considering all pixel ray measurements that traverse it. However, we observe that, due to the particular structure of the inverse sensor model, we can make a conservative decision based on the measured depth $z$ and the point's query depth $r = \mathbf{T}_{WC_k}^{-1} {_W\mathbf{p}}\vert_z$ on whether to split the node by only considering the span of measurements $[z_{\min}, z_{\max}]$, and query depths $[r_{\min}, r_{\max}]$ in the node's volume, as illustrated in Fig. \ref{fig:voxels_3d}.

While the span $r_{\min,\max}$ can be easily computed from the node's position and size, $z_{\min,\max}$ is more involved. To compute the latter, the node is projected into the depth image defining a bounding box (BB). More importantly, instead of evaluating all pixels within the BB, we sample a pre-computed \edit{set} of min-max pooling images.
}

\begin{figure}[t]
    \centering
    \includegraphics[ width=1.00\columnwidth]{images/flow_chart.pdf}
    \caption{\edit{The process to decide whether a node should be updated, split or skipped. From the projection bounding box (BB-O), simple queries $\mathbf{P}^f_k[u,v]$ to the pooling image at the correct scale $f$ provide an span of measurements $[z_{\min}, z_{\max}]$  which is used alongside the inverse sensor model and the span of query depths $[r_{\min}, r_{\max}]$ in the node's volume to make a decision (shown for 3 possible cases $N_1-N_3$). The node is also split if pooling indicates it projects into partly unknown data or crosses the frustum.}}
    \label{fig:voxels_3d}
\end{figure}

Each pooling image $\mathbf{P}^f_k \in \mathbb{R}^{H \times W}$ with $f \in \{1, \dots, f_{\max}\}$ aggregates the information of the original depth image for different square areas $A^f = (2^f+1)^2$ centred around each pixel with coordinates $u$ and $v$. More specifically, pixel $\mathbf{P}^f_k[u,v]$ holds the span of measurement $z_{\min,\max}$ within $A^f$, as well as a validity and an image crossing state to handle invalid data and image boundaries. These pooling images are computed recursively from the previous level by summarising $\mathbf{P}^{f-1}_k[u\pm2^{f-2},v\pm2^{f-2}]$ as shown in Fig. \ref{fig:voxels_3d}. Once this structure is computed, a conservative evaluation of \eqref{eq:split_crit} can be made by simply computing a BB of the \edit{projected node} in the image and  querying the max-min pooling at the level with the maximum square size that is still fully contained in the BB, reducing the amount of queries needed to decide whether to split the node to no more than 4 in the majority of cases.
\edit{In summary, by considering measurement spans we reduce the problem of evaluating (\ref{eq:split_crit}) from a 3D sampling to a 2D one, which is further reduced to a few samples using a pre-computed set of pooling images. }

\subsection{Multi-resolution Probabilistic Occupancy Fusion}
\label{section:Fusion}
While data at node level may be at various resolutions, \edit{once voxel block level is reached, each block} is evaluated at a common resolution scale $s_c$, further improving performance, reducing aliasing effects and simplifying interpolation required by operations like raycasting and meshing.
Similar to \cite{Vespa2019}, measurements are integrated at a mip-mapped scale in the voxel block based on the current distance from the block centre to the camera. Moreover, we integrate blocks that are known to only contain frontiers from free to unknown space not finer than scale $s_f$. \edit{This way, the maximum level of detail ($s_f >= 0$) of the frontier boundaries can be chosen independently of the surface (see Fig. \ref{fig:quadtree} for $s_f = 1$}).

The desired integration scale $s_d$ may change with the distance.
In contrast to \cite{Vespa2019}, we apply a scale change hysteresis requiring the camera to move a certain amount. \edit{Given the focal length $c$ and the map resolution $v_{\text{res}}$, the camera has to move} $\Delta _C\mathbf{m}_z = 0.25 \times c \times v_{\text{res}}$ closer to or further away from the voxel block before changing the scale again, to avoid constant scale changes of blocks located at a scale boundary.

We adapt the propagation strategies applied in \cite{Vespa2019}, to our occupancy map representation to keep the hierarchy consistent between scale changes.
We replace the parent with the mean of all observed children when up-propagating information to a coarser mip-mapped scale ($s_d > s_c$). However, when down-propagating to a finer integration scale ($s_d < s_c$), we allocate the data first and assign the parent's value to all its children. In either case, we do not change scale immediately. Instead we wait for the block to be fully projected into the image plane multiple times and observed at the desired scale $s_d$. During this time we update the data at both scales $s_c$ and $s_d$. Once the changing condition is fulfilled we switch to the new integration scale, deleting the previous buffer. This reduces artefacts by smoothing values during initialisation and preventing blocks that are occluded or just about to exit the camera frustum from changing scale. \edit{In comparison to prior work our new down-propagation strategy enables eliminating all helper variables stored in each voxel, thereby drastically reducing memory consumption.}

Once all information from a depth image $\mathbf{D}_k$ is integrated into the map, the mean values of all updated blocks are up-propagated to the mip-mapped scale within each block to enable tri-linear interpolation between neighbours of different scales.
Additionally, the maximum occupancy of all updated blocks and nodes is propagated through all levels up to the root of the tree to support fast hierarchical free space queries. Finally, pruning is applied to merge node children whose weighted log-odd occupancy is close enough according to a lower threshold $L_{\min}$. This extra step simplifies the tree when the occupancies converge to similar values.

\subsection{Multi-resolution Ray-casting and Meshing Modules}
\label{subsec:raycasting}
Fast raycasting is required to render the surface in real-time and/or to enable tracking as part of a full dense SLAM system. With the up-propagated maximum occupancy and observed state stored in our data structure, we implemented a multi-resolution ray-casting strategy to quickly move a ray through large volumes of free space \cite{Knoll2006}.

A meshing module is also provided which computes an adaptive resolution dual mesh following \cite{Wald2020}. This approach had been adapted to support our two tier data structure.

\section{Evaluation}
\label{sec:experimental_results}
\begin{figure*}[htb]
    \centering
    \subfloat[]{\includegraphics[trim={0.0cm 3.3cm 0.0cm 3.3cm},clip,height=2.1cm]{images/cow_and_lady_mof_mesh_color_s.jpeg}}
    \hspace{0.1cm}
    \subfloat[]{\includegraphics[trim={0.0cm 3.2cm 0.0cm 1.0cm},clip,height=2.1cm]{images/long_office_s.jpeg}}
    \hspace{0.1cm}
    \subfloat[]{\includegraphics[trim={0.0cm 2.1cm 0.0cm 2.1cm},clip,height=2.1cm]{images/ICL_Mesh_Color_full_s.jpeg}}
    \hspace{0.1cm}
    \subfloat[]{\includegraphics[height=2.1cm]{images/ICL_Mesh_Color.jpeg}}
    \hspace{0.1cm}
    \subfloat[]{\includegraphics[height=2.1cm]{images/ICL_Mesh_Gray.jpeg}}
    \caption{Our multi-scale mesh reconstruction for different sensor types with green encoding sampling scale 0 (finest) and orange scale 1. (a) In the \textit{Cow and Lady} dataset and (b) \textit{TUM} dataset, scale is adapted to reflect higher Kinect sensor noise, particularly for places far from sensor trajectory, which loops around the central desk. (c) In the \textit{ICL-NUIM} synthetic dataset a similar model is used to show how, in lack of noise, no artefacts appear due to scale changes. (d) A close up in ICL showing an scale change in a wall. (e) Same as (d) but with uniform color, showing the lack of artefacts in the transition.}
    \label{fig:mesh}
\end{figure*}
This section presents our experimental results.
All our tests were performed on an Intel Core i7-8750H
CPU operating at 2.20 GHz, 16 GB of memory, and running Ubuntu 18.04.
We used GCC 7.4.0 with OpenMP acceleration for software compilation.
For computing the TSDF with \textit{voxblox} \cite{Oleynikova2017} the \textit{fast} method was used in all comparisons, \textit{OctoMap} \cite{Hornung2013}, \textit{UFOMap} \cite{Duberg2020} and \textit{voxblox} were run in ROS.
The parameter values used in the experiments are shown in Table \ref{tab:params} unless otherwise specified.
Three widely known datasets were used to quantitatively evaluate our system: \textit{TUM} RGB-D \cite{Sturm2012},  \textit{Cow and Lady} \cite{Oleynikova2017} and \textit{ICL-NUIM} \cite{Handa2014}.

\begin{table}[htb]
    \centering

    \begin{tabular*}{\columnwidth}{@{\extracolsep{\fill} } c c c c}
            \hline
		$f_{\max} = 5$ (\text{QVGA}) & \multicolumn{3}{c}{$s_f = 0$ ($v_{\text{res}} = 8\text{ cm}$)}
		 \\

		$f_{\max} = 6$ (\text{VGA})&
		\multicolumn{3}{c}{$s_f = 1$ ($v_{\text{res}} \in \{1 \text{ cm}, 2 \text{ cm}\}$)} \\
        \hline
		$l_{\min, \text{total}} = -100$ &
		$l_{\min, \text{iter}} = -5.015$ &
		\multicolumn{2}{c}{$L_{\text{min}}=0.95 \times l_{\min, \text{total}}$} \\

		$\sigma_{\min} = v_{\text{res}}$ &
		$\sigma_{\max} = 3 \times v_{\text{res}}$  &
		$z_{\mathrm{np}} = 0.4$ m & $z_{\mathrm{fp}} = 6$ m \\
		$\tau_{\min} =  3 \times v_{\text{res}}$ &
		$\tau_{\max} = 12 \times v_{\text{res}}$ &
		\multicolumn{2}{c}{$w_{\max} = l_{\min,  \text{total}} / l_{\min,  \text{iter}}$} \\

        \hline
        Cow and Lady       & \multirow{2}{*}{$\sigma(z) = 0.0025 \, {z}^2$} & \multicolumn{2}{c}{\multirow{2}{*}{$\tau(z) = 0.05 \, z$}} \\
        FR3 - Long Office  &  &\\
        ICL - LR2          & $\sigma(z) = 0.05 \, {z}$      & \multicolumn{2}{c}{$\tau(z) = 0.05 \, z$} \\
        \hline
    \end{tabular*}
    \caption{Parameter values used in the experiments.}
    \label{tab:params}
\end{table}

\subsection{Reconstruction Accuracy}
To evaluate how our method performs in terms of surface reconstruction, we evaluate in the \textit{ICL-NUIM Living Room 2} dataset  \cite{Handa2014}.
Table \ref{tbl:mesh} shows the reconstruction \ac{RMSE} to the ground truth mesh as computed by the \textit{SurfReg} tool provided by the dataset, with given poses and without extra ICP alignment.
Our method outperforms previous approaches on both tested resolutions.

Additionally, we investigate the potential degradation induced by down-sampling the input image. It can be seen the effect on the reconstruction metric in all cases is minor, motivating the use of this later step for improving both running time and memory usage.
To show how our method can adaptively select sampling resolution, multiple reconstructions are presented in Fig. \ref{fig:mesh} with color encoding scale.

\begin{table}[htb]
    \centering
    \begin{tabular*}{\columnwidth}[b]{@{\extracolsep{\fill} } l c c c}
        & Image scale & 1 cm & 2 cm \\
        \hline
        \multirow{2}{*}{Ours} & $\times1$   & 0.0146 & \textbf{0.0193} \\
                              & $\times0.5$ & \textbf{0.0250}          & \textbf{0.0341} \\
        \hline
        \multirow{2}{*}{SE OFusion} & $\times1$   & 0.0166        & 0.0259 \\
                                    & $\times0.5$ & 0.0478        & 0.0465 \\
        \hline
        \multirow{2}{*}{SE TSDF} & $\times1$    & \textbf{0.0142} & 0.0200 \\
                                 & $\times0.5$  & 0.0429           & 0.0367 \\
        \midrule
    \end{tabular*}
    \caption{Reconstructed mesh RMSE [m] on the \textit{ICL-NUIM LR2} dataset for different resolution and image subsampling.}
    \label{tbl:mesh}
\end{table}
\begin{figure}[htb]
    \centering
    \subfloat{\includegraphics[trim={0.0cm 7.0cm 0.0cm 2.0cm},clip,width=0.49\columnwidth]{images/long_office_ufomap_s.jpeg}}
    \hspace{0.005cm}
    \subfloat{\includegraphics[trim={0.0cm 7.0cm 0.0cm 2.0cm},clip,width=0.49\columnwidth]{images/long_office_mof_s.jpeg}}
    \caption{Voxelised reconstruction in FR3 - Long Office for \textit{UFOMap} ($n = 0, d \hat{=} 16cm$, their visualiser) (\textbf{left}) and our system (\textbf{right}). Note the holes in the \textit{UFOMap} surface due to non-conservative free space allocation.}
     \label{fig:long_office_compare}
\end{figure}

\subsection{Runtime Performance}
\begin{figure*}[htb]
    \centering
    \subfloat{\includegraphics[trim={5.0cm 3.5cm 10cm 5cm},clip,width=0.33\textwidth]{images/timings_1cm_new.png}}
    \subfloat{\includegraphics[trim={5.0cm 3.5cm 10cm 5cm},clip,width=0.33\textwidth]{images/timings_2cm_new.png}}
    \subfloat{\includegraphics[trim={5.0cm 3.5cm 10cm 5cm},clip,width=0.33\textwidth]{images/timings_8cm_new.png}}
    \caption{Timings for our system alongside other planning libraries, including the widely used \textit{OctoMap} \cite{Hornung2013}, for 1cm (\textbf{left}), 2cm (\textbf{centre}) and 8cm (\textbf{right}) maximum resolution. Notice the logarithmic scale. In the case of \textit{voxblox} both timings for TSDF and ESDF calculation are shown, as both are needed for path planning. For some libraries including ours, results are presented for full resolution input images ($\times 1$) and down-sampled images ($\times 0.5$). The cost for computing data up-propagation (pooling) in our method is also separated to highlight the cost of having this multi-resolution feature in our map.}
    \label{fig:timings}
\end{figure*}

Running times for our system and competing methods can be seen in Fig. \ref{fig:timings}. Our method performs best at 1cm resolution for both image configurations, beating other methods in datasets using real sensors.
\edit{We attribute this mainly to our adaptive-scale approach which leverages the additional computations needed to accurately and conservatively represent free-unknown space with economising resolution where not needed.
As maximum resolution decreases to 8cm, or in small datasets, e.g. ICL-NUIM, the benefits of adaptive-scale are less pronounced while small costs like computing a pooling image become relatively larger. This is expected and consistent with the high-resolution/large-scale environments targeted by the algorithm.}

\edit{Methods like \textit{OFusion} and \textit{UFOMap} (\textit{fast}) also achieve excellent performance but at the expense of mapping quality, as shown in Section~\ref{subsec:planning} and Fig.~\ref{fig:long_office_compare}.  Additionally, methods such as} \textit{voxblox} present reasonable results, but have the drawback of requiring an extra step of computing an  ESDF in order to allow direct planning on them, which becomes prohibitively expensive in high resolution cases. This limits its usability in cases requiring a high resolution navigable map in real-time. Finally \textit{OctoMap} presents significantly higher integration times than newer methods, since it targets low resolution LIDAR made maps.

\subsection{Multi-resolution, Memory and Efficiency}
To assess memory efficiency of our multi-resolution approach,
we compare our memory usage to supereight OFusion \cite{Vespa2018} and supereight MutiresTSDF \cite{Vespa2019}. In particular OFusion uses an octree, similarly to our system for storing both free and occupied space, while MultiresTSDF also utilises an octree but for sparsely allocating a narrow-band TSDF.

As a conservative measurement of memory usage, we use the main process' Resident Set Size (RSS) as reported by the Linux kernel to compute the RAM usage.

\begin{table}[htb]
    \centering
    \begin{tabular*}{\columnwidth}[b]{@{\extracolsep{\fill} } l c c | c c | c c}
        & \multicolumn{2}{c}{Cow \& Lady} & \multicolumn{2}{c}{FR3 Long Office} & \multicolumn{2}{c}{ICL LR2} \\
        \cline{2-7}
        & 1cm & 8cm & 1cm & 8cm & 1cm & 8cm \\
        \hline
        Ours       & \textbf{1100}  & 65          & \textbf{493} & 62          & 397          & 105\\
        \hline
        SE OFusion & 1734           & \textbf{57} & 1009         & \textbf{56} & \textbf{192} & \textbf{54}\\
        \hline
        SE MultiresTSDF    & 2922   & 65          & 1728         & 68          & 406          & 56\\
        \midrule
    \end{tabular*}
    \caption{Memory consumption in MB at different voxel resolutions.}

    \label{tbl:memory}
\end{table}

Results can be seen in Table~\ref{tbl:memory}. For the intended use case of high resolution reconstruction and planning, our system overcomes competing methods in real life scenarios, mainly thanks to the adaptive sampling resolution at voxel block level. As resolution decreases, or in small datasets, e.g. \textit{ICL-NUIM}, where the relative voxel block size grows in a way that brings the allocation near to dense, the cost of storing this extra multi-resolution information along with our conservative allocation of frustum boundaries, takes a toll on the usage when compared to simpler methods like OFusion. This extra cost is justified by superior planning performance.

\subsection{Tracking Performance}

\label{subsec:tracking}
In this section, we evaluate our mapping system integrated to a Dense SLAM Pipeline similar to \cite{Newcombe2011}, which is included as an additional component of the presented library.

Table \ref{tab:ate} shows trajectory accuracy results using the \ac{ATE} metric against TSDF and OFusion \cite{Vespa2018} methods on the FR1 - Desk and FR3 - Long Office sequences of the \textit{TUM} RGB-D datasets.
The same ICP tracking approach presented in \cite{Newcombe2011} is used for all pipelines. For point-cloud extraction our system relies on the efficient multi-resolution raycasting method described in Section \ref{subsec:raycasting}.
Results indicate that maps produced by our approach are suitable for accurate ICP tracking, with the \ac{ATE} being similar to that of previous methods.
\begin{table}[htb]
    \centering
    \scriptsize
    \begin{tabular*}{\columnwidth}{@{\extracolsep{\fill} } l c c c c}
        & \multicolumn{4}{c}{ATE (m)} \\
        \cline{2-5}
        & \multicolumn{2}{c}{FR1 - Desk} & \multicolumn{2}{c}{FR3 - Long Office} \\
        \cline{2-3} \cline{4-5}
        Pipeline & 1 cm & 2 cm & 1 cm & 2 cm \\
        \hline
        Ours               & 0.104 & 0.098          & 0.194           & 0.185 \\
        SE TSDF            & \textbf{0.099}          & 0.103          & 0.314           & FAIL \\
        SE OFusion         & 0.100          & \textbf{0.086} & \textbf{0.165}  & \textbf{0.172} \\
        \midrule
    \end{tabular*}
    \caption{\ac{ATE} of various pipelines on \textit{TUM} RGB-D datasets.

    }
    \label{tab:ate}
\end{table}

\begin{figure}[htb]
    \centering
    \subfloat{\includegraphics[trim=4cm 0cm 2.1cm 0cm,clip,width=0.5\columnwidth]{images/Planning_MRes_s.jpeg}}
    \hspace{0.1cm}
    \subfloat{\includegraphics[width=0.44\columnwidth]{images/the_newer_college_planning_s.jpeg}}
    \caption{(\textbf{left}) Planning in the \textit{Cow and Lady} dataset : Trajectory 1 over the cow obtained with our mapping system, OFusion is unable to solve this planning problem due to clutter. (\textbf{right}) Planning in The Newer College dataset \cite{Ramezani2020}:  Trajectores 3 (\textbf{orange}) and  4 (\textbf{red}). Remarkably the method is able to find the shortest path though the centre corridor.}
     \label{fig:traj1}
\end{figure}

\subsection{Planning}
\label{subsec:planning}
Finally, we evaluate our mapping system as input for path planning. We show that kinodynamically feasible and collision free quadrotor trajectories with map resolutions up to 1cm can be planned in real-time. To guarantee feasibility, we compute a \ac{SFC} from the start to the end position and optimise $10^{th}$ order Bernstein polynomial motion primitives within each segment. As a corridor primitive we use cylinders connected by spheres with a minimum radius $r_{\min}$. We use the open motion planning library's (OMPL \cite{Sucan2012}) informed rapidly-exploring random tree* (informed RRT* \cite{Gammell2014}) planner to create the \ac{SFC} connecting the start and end positions. OMPL confirms the safety of each corridor segment by verifying that none of the cylinder and sphere volumes is occupied. This is challenging using a regular volumetric grid where the number of checks grows cubically with the map resolution.

With our multi-resolution maximum occupancy queries, we utilise a `coarse-to-fine' collision checking approach recursively increasing the resolution in parts of the corridor where needed to reduce the number of checks required.
\begin{figure}[htb]
    \centering
    \subfloat{\includegraphics[width=0.48\columnwidth]{images/Planning_OF2_s.jpeg}}
    \hspace{0.1cm}
    \subfloat{\includegraphics[width=0.48\columnwidth]{images/cal_of_1cm_2ds_s.jpeg}}
    \caption{(\textbf{left}) Clutter in OFusion makes the planner fail in several cases; (\textbf{right}) For a different problem (Trajectory 2) both systems find a solution but OFusion struggles with noise while planning times with our pipeline are significantly lower.}
    \label{fig:traj2}
\end{figure}

We investigate the use of our method for several path planning problems illustrated in Figs.~\ref{fig:traj1} and~\ref{fig:traj2}  and compare against the OFusion library, which also achieves excellent mapping times and provides some multi-resolution output. While our method can find suitable trajectories in every iteration, notably in cluttered datasets like the \textit{Cow and Lady} or large scale like \textit{The Newer College} \cite{Ramezani2020}, OFusion fails in several cases. This is because OFusion lacks a proper mechanism for leveraging information from different scales, instead relying on a simple rule of giving preemptiveness to data in high resolution voxel blocks over values stored at node levels. Given that the latter normally stores information about free space observations and the former allocates surface measurements, OFusion is fast but heavily biased against noise measurements and outliers. In our system we solve this issue by not only propagating data down from nodes to voxel blocks, but also by carefully considering the variation of occupancy inside the node's whole volume (not only the centre value), as described in Section~\ref{subsec:map_to_cam}, to avoid having the opposite effect of biasing towards free space.

To further confirm these aspects and highlight the benefits of our library, we modified OFusion to perform dense allocation, i.e. everything integrated at a single lowest voxel block level. The results in Table \ref{tbl:planning_timings} show the minimum solving time required by the planner to find a \ac{SFC}. While the dense allocation approach can remove OFusion noise and find suitable trajectories, the planning time required is much higher. This is easily explained by the lack of multi-resolution sampling capabilities, a key feature of our system.

\begin{table}[htb]
    \centering
    \begin{tabular*}{\columnwidth}[b]{@{\extracolsep{\fill} } l c c c c}
        & Traj 1 &  Traj 2 & Traj 3 & Traj 4\\
        \hline
        Ours                & \textbf{0.01} & \textbf{0.1} & \textbf{0.06} & \textbf{0.4} \\
        \hline
        SE OFusion          & 4             & FAIL (too noisy)            & 3             & FAIL (too noisy) \\
        \hline
        SE Dense            & 5             & 15           & 3             & 6 \\
        \midrule
    \end{tabular*}
    \caption{Minimum times (sec) to compute 'Safe Flight Corridor'. }
    \label{tbl:planning_timings}
\end{table}

\section{Conclusion}
\label{sec:conclusion}
We have introduced a multi-resolution 3D mapping framework that is using an underlying two-tier octree data structure to encode log-odds occupancy probabilities.
Thanks to explicit free space encoding in a hierarchical way, the approach supports fast collision checking, crucial in robotic path planning and collision avoidance, while providing high resolution reconstructions simultaneously.

Our framework was evaluated extensively in synthetic and real-world RGB-D datasets: we showed that surface accuracy is competitive with state-of-the-art TSDF-based frameworks, while enabling real-time or near-real-time operation even at centimetre-level resolutions.
We finally show our maps used in different real-time 3D trajectory scenarios, including large scale LIDAR ones, to dramatically improve planning time without converting the map into ESDF as required by many existing approaches; thus providing seamless, unprecedented integration between mapping and planning.

\bibliographystyle{IEEEtran}