Tutorials › Statistical Learning (Graduate) › Choosing the Series Truncation Dimension

Nonparametric Density Estimation · Tutorial 604 of 989

Choosing the Series Truncation Dimension

Learn to balance series bias and variance, derive the truncation dimension and risk rates, and interpret how smoothness and ambient dimension affect the choice.

Intermediate 10 min read

What You'll Learn

  • Express the integrated risk bound as approximation error plus variance.
  • Derive the continuous truncation dimension that minimizes the bound.
  • Translate the continuous choice into a valid integer dimension.
  • Obtain the resulting integrated squared-error rate.
  • Interpret the effects of smoothness and ambient dimension without confusing their directions.
  • Distinguish oversmoothing from undersmoothing in series truncation.

Why the Truncation Dimension Matters

An orthonormal series density estimator uses only a finite number of basis functions to represent an unknown density. The truncation dimension \(m\) controls a direct trade-off: a small \(m\) may leave important structure out of the estimate, while a large \(m\) requires estimating more coefficients from the same sample. Choosing \(m\) means balancing these two sources of integrated error, rather than maximizing the number of terms or minimizing approximation error alone.

This tutorial derives that balance under a Hölder-smoothness approximation bound. The resulting dimension is a rate-level choice: constants, the basis, and the sample size can affect the best finite-sample integer. The main conclusions concern how the dimension and risk scale with \(n\), smoothness \(\beta\), and ambient dimension \(d\).

Setup: Approximation Error and Variance

Let \(X_1,\ldots,X_n\) be independent observations from a density \(f\) on a \(d\)-dimensional domain, and let \(\{\phi_j\}_{j\geq 1}\) be an orthonormal basis for the relevant \(L^2\) space. Write \(\theta_j=\int \phi_j(x)f(x)\,dx\) and estimate each coefficient by \(\hat\theta_j=n^{-1}\sum_{i=1}^n\phi_j(X_i)\). The series estimate truncated at \(m\) terms is \(\hat f_m=\sum_{j=1}^m\hat\theta_j\phi_j\). Its integrated squared-error risk is \(E[\|\hat f_m-f\|_2^2]\).

The earlier material on projection bias and series variance gives the guiding decomposition: integrated risk is the squared error from projecting \(f\) onto the first \(m\) basis functions plus the variance from estimating their coefficients. For the basis and smoothness class under consideration, assume the following bounds hold uniformly over the candidate dimensions:

$$ \text{approximation error}\ \leq A m^{-2\beta/d}, \qquad \text{variance}\ \leq \frac{Bm}{n}, $$

Here \(\beta>0\) is the Hölder smoothness, \(d\geq1\) is the ambient dimension, and \(A,B>0\) do not depend on \(m\) or \(n\). The approximation bound describes how well the first \(m\) terms can represent densities in the class; the variance bound describes the cost of estimating \(m\) coefficients. Thus an upper bound for the risk is

$$ R_n(m)\ \leq\ A m^{-\alpha}+\frac{Bm}{n}, \qquad \alpha=\frac{2\beta}{d}. $$

This bound is the object we optimize. If it is only an upper bound, its minimizer optimizes the bound, not necessarily the exact finite-sample risk. When the bias and variance are also bounded below by constant multiples of these expressions, the same calculation describes the risk order of an optimal choice.

Worked Example: Writing the Trade-Off

Suppose \(d=2\), \(\beta=1\), and the constants are \(A=3\) and \(B=2\). Then \(\alpha=2\beta/d=1\), so the risk bound as a function of the integer dimension is

$$ R_n(m)\leq \frac{3}{m}+\frac{2m}{n}. $$

The first term decreases when \(m\) increases, while the second increases. For instance, at \(n=100\), \(m=10\) gives the bound \(3/10+20/100=0.5\). Taking \(m=20\) lowers the approximation part to \(3/20=0.15\), but raises the variance part to \(40/100=0.4\), giving \(0.55\). More terms improve representation but need not improve total risk.

Deriving the Optimal Continuous Dimension

First treat \(m\) as a positive real number. This simplifies the optimization; an actual series estimator must use an integer dimension, which will be handled afterward. Define the bound \(G_n(m)=A m^{-\alpha}+Bm/n\). Its derivative is

$$ G_n'(m)=-\alpha A m^{-\alpha-1}+\frac{B}{n}. $$

The derivative is strictly increasing in \(m>0\), since \(G_n''(m)=\alpha(\alpha+1)A m^{-\alpha-2}>0\). It is negative for sufficiently small \(m\) and positive for sufficiently large \(m\), so its unique zero is the global minimizer.

Theorem: For \(A,B,\alpha>0\) and \(n>0\), the unique minimizer of \(G_n(m)=A m^{-\alpha}+Bm/n\) over real \(m>0\) is
$$ m_c=\left(\frac{\alpha A n}{B}\right)^{1/(\alpha+1)} =\left(\frac{(2\beta/d)A n}{B}\right)^{d/(2\beta+d)}. $$
At this choice, the variance term equals \(\alpha\) times the approximation term, and the minimized bound has order \(n^{-2\beta/(2\beta+d)}\), with \(A,B,\beta,d\) fixed.

Proof. Setting the derivative equal to zero gives

$$ -\alpha A m^{-\alpha-1}+\frac{B}{n}=0 \quad\Longleftrightarrow\quad m^{\alpha+1}=\frac{\alpha A n}{B}. $$

Taking the positive \((\alpha+1)\)st root yields \(m_c=(\alpha A n/B)^{1/(\alpha+1)}\). Strict positivity of the second derivative shows this stationary point is the unique global minimum. At the stationary point, the derivative equation also gives \(Bm_c/n=\alpha A m_c^{-\alpha}\). Therefore

$$ G_n(m_c)=(1+\alpha)A m_c^{-\alpha} =(1+\alpha)A\left(\frac{\alpha A n}{B}\right)^{-\alpha/(\alpha+1)}. $$

Finally, \(\alpha/(\alpha+1)=2\beta/(2\beta+d)\), so with the other quantities fixed this expression is a constant times \(n^{-2\beta/(2\beta+d)}\). Substituting \(\alpha=2\beta/d\) into the expression for \(m_c\) gives the stated dimension formula. \(\square\)

The two contributions at the optimum are therefore comparable, but they are not generally equal: their ratio is set by \(\alpha\). In rate calculations, one often writes \(m\asymp n^{d/(2\beta+d)}\), suppressing fixed positive constants. Substituting any such dimension into the two terms gives the same risk order \(n^{-2\beta/(2\beta+d)}\).

Worked Example: Smoothness Changes the Dimension Exponent

Take \(d=1\), \(A=B=1\), and \(n=100\). When \(\beta=1\), \(\alpha=2\), and the continuous optimum is

$$ m_c=(2\cdot100)^{1/3}=200^{1/3}\approx5.85. $$

The integer candidates around this value are 5 and 6. The bound at 5 is \(1/25+5/100=0.09\); at 6 it is \(1/36+6/100\approx0.08778\). Since the continuous bound decreases up to \(m_c\) and increases after it, the integer minimizer is 6.

Now keep \(d,A,B,n\) the same and set \(\beta=2\). Then \(\alpha=4\), giving

$$ m_c=(4\cdot100)^{1/5}=400^{1/5}\approx3.31. $$

The candidates 3 and 4 give \(1/3^4+3/100=1/81+0.03\approx0.04235\) and \(1/4^4+4/100=1/256+0.04\approx0.04391\), respectively. The integer minimizer is 3. In this example the higher smoothness improves the optimized risk bound but gives a smaller, not larger, optimal dimension. This is not a universal finite-sample comparison: constants and the exact risk can change the integer choice.

From a Real-Valued Optimum to an Integer Choice

The formula for \(m_c\) is not itself an estimator dimension unless it happens to be an integer. Rounding is harmless for the rate, provided the candidate dimensions are available and \(m_c\) is not confined to a small-sample boundary. The next result makes this precise for all positive integer dimensions.

Result: If \(m_c\geq2\), an integer dimension \(m\) can be chosen with \(m\in\{\lfloor m_c\rfloor,\lceil m_c\rceil\}\) such that
$$ G_n(m)\leq \max(2^\alpha,2)\,G_n(m_c). $$
Thus rounding changes the optimized bound by at most a constant factor independent of \(n\).

Derivation. Let \(k=\lfloor m_c\rfloor\). Since \(m_c\geq2\), \(k\geq m_c/2\), and \(k\leq m_c\). Consequently

$$ A k^{-\alpha}\leq 2^\alpha A m_c^{-\alpha}, \qquad \frac{Bk}{n}\leq \frac{Bm_c}{n}. $$

Adding these inequalities shows \(G_n(k)\leq\max(2^\alpha,1)G_n(m_c)\), which is no larger than the displayed bound. The integer minimizer has a bound no greater than \(G_n(k)\). Alternatively, \(q=\lceil m_c\rceil\) satisfies \(q\geq m_c\) and \(q\leq2m_c\), so \(Aq^{-\alpha}\leq A m_c^{-\alpha}\) and \(Bq/n\leq2Bm_c/n\), giving the same constant-factor conclusion. This proves the result. \(\square\)

In the usual asymptotic setting, \(m_c\) grows with \(n\), so \(m_c\geq2\) eventually. If only a restricted sequence of dimensions is available, such as a set of block sizes, the rounding argument requires that an available dimension be within a fixed multiplicative factor of \(m_c\). The rate conclusion then follows by the same comparison. For very small samples, constraints such as a minimum dimension may instead determine the practical choice.

How Smoothness and Dimension Affect the Rates

The optimal dimension and risk have different exponents:

$$ m_c\asymp n^{q},\qquad q=\frac{d}{2\beta+d}, \qquad G_n(m_c)\asymp n^{-r},\qquad r=\frac{2\beta}{2\beta+d}. $$

For fixed \(d\), increasing \(\beta\) decreases \(q\), since

$$ \frac{\partial q}{\partial\beta} =-\frac{2d}{(2\beta+d)^2}<0, \qquad \frac{\partial r}{\partial\beta} =\frac{2d}{(2\beta+d)^2}>0. $$

Thus greater smoothness improves the risk exponent but makes the optimal dimension grow more slowly with sample size. This does not assert that the optimal finite-sample dimension must decrease in every comparison: \(A\), \(B\), the basis, and integer rounding also matter.

For fixed \(\beta\), increasing \(d\) has the opposite effect on the dimension exponent and the risk exponent:

$$ \frac{\partial q}{\partial d} =\frac{2\beta}{(2\beta+d)^2}>0, \qquad \frac{\partial r}{\partial d} =-\frac{2\beta}{(2\beta+d)^2}<0. $$

The dimension therefore grows faster with \(n\) as \(d\) increases, while the risk rate becomes slower. This reflects the fact that representing a density with the same smoothness becomes more demanding in a higher-dimensional domain.

Worked Example: Comparing Dimension and Risk Exponents

Set \(\beta=1\). In dimension \(d=1\), the exponents are \(q=1/(2+1)=1/3\) and \(r=2/(2+1)=2/3\). In dimension \(d=2\), they are \(q=2/(2+2)=1/2\) and \(r=2/(2+2)=1/2\). For \(n=1000\), the dimension factors \(n^q\) are approximately \(1000^{1/3}=10\) and \(1000^{1/2}\approx31.62\), respectively. The risk factors are \(1000^{-2/3}=0.01\) and \(1000^{-1/2}\approx0.03162\).

These are rate factors, not exact dimension or risk values; the fixed constants in the formulas have been omitted. The calculation checks both directions: the dimension exponent is larger in the higher-dimensional case, while the risk decreases more slowly with \(n\).

Practical Interpretation and Common Pitfall

A useful selection rule is to choose an available dimension on the order of \(n^{d/(2\beta+d)}\), with constants informed by the approximation and variance scales when they are known. The smoothness \(\beta\) is often unknown in practice, so this formula alone does not supply an adaptive data-driven rule. It describes the target balance when the smoothness class and constants are specified.

In the usual bias–variance terminology for this truncation problem, too few retained terms create excessive approximation error and are called oversmoothing. Too many terms retain noisy coefficient estimates and are called undersmoothing. The words can be used differently in other contexts, so the underlying error description is more important than the label.

  • Pitfall: “Greater smoothness always means a larger optimal dimension.” This does not follow from the rate formula. For fixed \(d\), the exponent \(d/(2\beta+d)\) decreases as \(\beta\) increases. The exact finite-sample choice can also depend on constants, so avoid asserting a universal ordering of dimensions.
  • Pitfall: “Higher dimension makes the optimal dimension grow more slowly with \(n\).” The exponent \(d/(2\beta+d)\) increases with \(d\). What becomes slower is the risk rate, because \(2\beta/(2\beta+d)\) decreases.
  • Pitfall: Reversing the smoothing labels. In this series-truncation setting, too few terms mean oversmoothing and excess bias; too many mean undersmoothing and excess variance.
  • Pitfall: Treating a bound's optimizer as an exact finite-sample oracle. The calculation optimizes \(A m^{-2\beta/d}+Bm/n\). If this only bounds the risk from above, the actual risk can have different constants or a different best integer.
Key takeaway: Balancing Hölder-class approximation error \(m^{-2\beta/d}\) against series variance \(m/n\) gives \(m\asymp n^{d/(2\beta+d)}\) and integrated risk of order \(n^{-2\beta/(2\beta+d)}\). Higher smoothness improves the risk exponent but lowers the dimension-growth exponent; higher ambient dimension raises the dimension-growth exponent but worsens the risk exponent.

Check Your Understanding

Use the bias–variance bound and its assumptions to answer the following.

  1. For \(\beta=1\) and \(d=3\), what powers of \(n\) describe the optimal dimension and the optimized risk bound?
  2. At the continuous optimum, what is the ratio of the variance term to the approximation term? Why need those terms not be equal?
  3. For fixed \(d\), how does increasing \(\beta\) change the dimension-growth exponent and the risk exponent?
  4. For fixed \(\beta\), how does increasing \(d\) change those two exponents?
  5. In this truncation setting, which error is associated with oversmoothing, and which with undersmoothing?
Clinical Biostats