<div class = "glossary-entry">
<h3>treedepth</h3>

<span class="help-block" style = "margin-top: 15px;">
  <em>Quick definition</em>
</span>

The depth of tree used by NUTS.
  
<br><br>  
<h4>More details</h4>

<p>
Configuring NUTS involves putting a cap on the depth of the 
trees that it evaluates during each iteration. This is controlled through 
a maximum depth parameter. <code>n_leapfrog</code> is then bounded 
by 2 to the power of the maximum depth minus 1.
</p>

<p>
Tree depth is an important diagnostic tool for
NUTS. For example, a <code>treedepth = 0</code> occurs when the first leapfrog 
step is immediately rejected and the initial state returned, indicating extreme
curvature and poorly-chosen <code>stepsize</code> (at least relative to the 
current position). 
</p>

<p>
On the other hand, <code>treedepth = max_treedepth</code> equal to the maximum depth
indicates that NUTS is taking many leapfrog steps and being terminated
prematurely to avoid excessively long execution time. 
</p>

<p>
Taking very many steps may be a sign of poor adaptation, 
may be due to targeting a very high acceptance rate, 
or may simply indicate a difficult posterior from which to sample. 
In the latter case, reparameterization may help with efficiency. But
in the rare cases where the model is correctly specified and a large number of
steps is necessary, the maximum depth should be increased to ensure that that
the NUTS tree can grow as large as necessary.
</p>
</div>
