Tutorials › Exam ASTAM - Advanced Short-Term Actuarial Mathematics › Weighted Kernel Density Estimation

Exam ASTAM · Kernel, Truncation, and Censoring · Tutorial 270 of 979

Weighted Kernel Density Estimation

Build and interpret a weighted kernel density estimate by normalizing unequal exposure weights and applying a common bandwidth correctly.

Advanced 10 min read

What You'll Learn

  • Define normalized weights and the weighted kernel density estimate.
  • Derive why the estimate integrates to one.
  • Calculate estimates using triangular and Epanechnikov kernels.
  • Interpret estimates when observations represent unequal exposure.
  • Distinguish exposure weighting from unweighted estimation and frequency replication.
  • Avoid normalization, bandwidth, and density-unit errors.

Why Weight a Kernel Density Estimate?

A kernel density estimate smooths observed losses into an estimated density. When observations represent unequal amounts of exposure, treating every observation equally may not describe the exposure-weighted loss distribution of interest. For example, a loss observation associated with 300 policy-years may reasonably receive more weight than one associated with 50 policy-years, provided the target is the distribution across exposure rather than the distribution across recorded observations.

This tutorial considers exact, nonnegative loss observations \(X_1,\ldots,X_n\), nonnegative weights \(w_1,\ldots,w_n\), and one common bandwidth \(h>0\). The weights may be exposure amounts or other prespecified measures of relative importance. This method does not by itself correct for incomplete observation or selection into a sample; the weight must represent the target population appropriately.

Definition: For weights with positive total \(W=\sum_{i=1}^n w_i\), the normalized weight of observation \(i\) is \(\alpha_i=w_i/W\). Thus \(\alpha_i\geq 0\) and \(\sum_{i=1}^n\alpha_i=1\). Given a kernel density \(K\) and bandwidth \(h>0\), the weighted kernel density estimate at loss level \(x\) is $$ \widehat f_{w,h}(x)=\sum_{i=1}^n \alpha_i\frac{1}{h}K\!\left(\frac{x-X_i}{h}\right) =\frac{1}{h\sum_{i=1}^n w_i}\sum_{i=1}^n w_iK\!\left(\frac{x-X_i}{h}\right). $$

A kernel \(K\) is typically a nonnegative density integrating to one; standard choices are symmetric about zero. For example, the triangular kernel is \(K(u)=(1-|u|)\) when \(|u|\leq 1\), and zero otherwise. The Epanechnikov kernel is \(K(u)=\tfrac{3}{4}(1-u^2)\) when \(|u|\leq 1\), and zero otherwise. The bandwidth \(h\) sets the smoothing scale. The argument \((x-X_i)/h\) is the standardized distance from observation \(i\) to the point \(x\).

Why the Normalization Works

Each observation contributes a kernel centered at \(X_i\), scaled horizontally by \(h\) and vertically by \(1/h\). The normalized weights determine how much probability mass that kernel contributes. The factor \(1/h\) is essential: stretching a kernel by \(h\) would otherwise multiply its area by \(h\).

1
Integrate one scaled kernel.
Use \(u=(x-X_i)/h\), so \(dx=h\,du\). Since \(K\) integrates to one, \(\int \frac{1}{h}K((x-X_i)/h)\,dx=\int K(u)\,du=1\).
2
Combine the weighted contributions.
By linearity of integration, the total area is \(\int \widehat f_{w,h}(x)\,dx=\sum_i\alpha_i\int \frac{1}{h}K((x-X_i)/h)\,dx\).
3
Apply the normalized-weight condition.
The preceding expression equals \(\sum_i\alpha_i=1\). Therefore, the weighted estimate is a density, as long as the kernel is a density and the weights are nonnegative with positive total.

This derivation also explains why normalizing by the number of observations \(n\) is generally wrong when the weights are unequal: it does not make the kernel contributions sum to one. Multiplying every weight by the same positive constant, however, leaves the estimate unchanged because the constant cancels between numerator and denominator.

Worked Example: A Triangular-Kernel Estimate With Unequal Weights

A hypothetical portfolio study records losses \(X_i=1,2,4\), measured in thousands of dollars, with exposure weights \(w_i=1,2,3\), respectively. Using a triangular kernel and common bandwidth \(h=2\) thousand dollars, calculate the weighted density estimate at \(x=3\) thousand dollars. State the units and check the weight normalization.

Method and normalized weights. The total weight is \(W=1+2+3=6\). The normalized weights are \(1/6,2/6,3/6\). The estimate is $$ \widehat f_{w,2}(3)=\frac{1}{2(6)}\sum_{i=1}^3w_iK\!\left(\frac{3-X_i}{2}\right). $$

Evaluate each kernel contribution. At \(X_1=1\), the standardized distance is \((3-1)/2=1\), so \(K(1)=0\). At \(X_2=2\), it is \(1/2\), so \(K(1/2)=1-1/2=1/2\). At \(X_3=4\), it is \(-1/2\), so \(K(-1/2)=1-1/2=1/2\). The weighted kernel sum is \(1(0)+2(1/2)+3(1/2)=0+1+1.5=2.5\).

Calculate and check. The denominator is \(hW=2(6)=12\), so the estimate is \(2.5/12=5/24=0.2083\) per thousand dollars, rounded to four decimal places. Equivalently, the normalized weights give \(\tfrac12[(1/6)(0)+(2/6)(1/2)+(3/6)(1/2)]=5/24\). The normalized weights sum to one, and the estimate has density units, not probability units.

Common mistake avoided: Dividing the weighted kernel sum \(2.5\) by \(hn=2(3)=6\) would give \(0.4167\), which is not the correctly normalized estimate. The denominator uses \(h\sum_iw_i=12\), not \(hn\).

Exposure Weights, Interpretation, and Units

The weighted estimate can be understood as smoothing a weighted empirical distribution. Before smoothing, that distribution places mass \(\alpha_i\) at each observed loss \(X_i\). After smoothing, the mass at \(X_i\) is spread over a neighborhood according to the kernel and bandwidth. If the weights are exposure amounts, the estimate describes losses for a randomly selected unit of the represented exposure, under the assumption that the observations and weights appropriately represent the target exposure.

This interpretation differs from simply asking for the distribution across recorded rows. An unweighted estimate assigns mass \(1/n\) to every row. An exposure-weighted estimate assigns mass \(w_i/W\). They coincide when all weights are equal, but not in general. Integer weights can produce the same formula as repeating observations that many times, but exposure weights need not be integer counts and should not automatically be interpreted as replicated claims.

The units of a density are the reciprocal of the units used for the loss variable. If losses are entered in thousands of dollars, the estimate is a density per thousand dollars. To express the corresponding density per dollar, divide the numerical value by 1,000. A density value is not itself a probability; probabilities are obtained by integrating the density over a loss interval.

Worked Example: Epanechnikov Kernel and Weight Scaling

For hypothetical exact losses \(10,12,14\) thousand dollars, the associated weights are \(2,1,3\). Use the Epanechnikov kernel, bandwidth \(h=2\) thousand dollars, and evaluate the weighted estimate at \(x=13\) thousand dollars. Then verify that rescaling all weights by the same factor would not change the answer.

Normalize the weights. The total is \(W=2+1+3=6\), giving normalized weights \(2/6,1/6,3/6\). In the raw-weight formula, the denominator is \(hW=2(6)=12\).

Evaluate the kernel values. For \(X_1=10\), the standardized distance is \((13-10)/2=1.5\), outside the kernel support, so \(K(1.5)=0\). For \(X_2=12\), the distance is \(0.5\), so \(K(0.5)=\tfrac34(1-0.5^2)=\tfrac34(0.75)=0.5625=9/16\). For \(X_3=14\), the distance is \(-0.5\), giving \(K(-0.5)=9/16\).

Combine the terms. The weighted kernel sum is \(2(0)+1(9/16)+3(9/16)=36/16=9/4\). Therefore, $$ \widehat f_{w,2}(13)=\frac{9/4}{12}=\frac{3}{16}=0.1875 $$ per thousand dollars, to four decimal places.

Check weight scaling. If the weights are changed from \(2,1,3\) to \(20,10,30\), the weighted kernel sum becomes \(10\) times as large, or \(90/4\), and the denominator becomes \(2(60)=120\). Their ratio remains \((90/4)/120=3/16\). This confirms that only relative weights matter.

Exposure-Weighted Versus Unweighted Estimates

The next calculation isolates the effect of unequal exposure. Consider three hypothetical loss observations, \(5,9,10\) thousand dollars, with respective exposure weights \(100,300,100\). Use a triangular kernel, bandwidth \(2\) thousand dollars, and evaluate at \(x=9\) thousand dollars.

Worked Example: Comparing Exposure-Weighted and Unweighted Results

Calculate the exposure-weighted estimate. The total weight is \(100+300+100=500\), so the normalized weights are \(0.2,0.6,0.2\). The standardized distances are \((9-5)/2=2\), \((9-9)/2=0\), and \((9-10)/2=-0.5\). The corresponding triangular-kernel values are \(0,1,0.5\). Thus, $$ \widehat f_{w,2}(9)=\frac{100(0)+300(1)+100(0.5)}{2(500)} =\frac{350}{1000}=0.3500. $$

Compare with an unweighted estimate. Giving each of the three rows weight one produces kernel sum \(0+1+0.5=1.5\) and denominator \(2(3)=6\). The unweighted estimate is \(1.5/6=0.2500\). The estimates differ because the observation at \(9\) thousand dollars represents more exposure than either of the other observations. The exposure-weighted result is \(0.3500\) per thousand dollars; it is not a claim that 35% of losses equal that value.

Check using normalized weights. Directly, the weighted estimate is \(\tfrac12[0.2(0)+0.6(1)+0.2(0.5)]=\tfrac12(0.7)=0.3500\), matching the raw-weight calculation.

Practical Checks and Common Exam Traps

A reliable calculation separates weight normalization from kernel evaluation. Write down the total weight, each normalized weight, the bandwidth, and the standardized distances before adding contributions. This makes it easier to detect whether a zero contribution lies outside a compact-support kernel and whether the bandwidth has been applied exactly once.

  • Using \(n\) instead of total weight. The denominator is \(hW\), where \(W=\sum_iw_i\). It becomes \(hn\) only when all weights are equal and can be canceled consistently.
  • Forgetting the bandwidth factor. The kernel term is \(K((x-X_i)/h)/h\), not just \(K((x-X_i)/h)\). Omitting \(1/h\) gives the wrong density scale and generally fails the unit-area check.
  • Using unnormalized weights as probabilities. The contributions must sum to total mass one. Divide each weight by \(W\), or use the equivalent raw-weight formula with denominator \(hW\).
  • Confusing density with probability. A value such as \(0.35\) per thousand dollars is a density height. A probability over an interval requires integrating the estimate over that interval.
  • Misreading the target. Exposure weighting changes the distribution being estimated. It is appropriate only when the weights represent the relative exposure relevant to the question; it is not a universal adjustment for unequal or incomplete observations.

For nonnegative losses, a standard symmetric kernel can assign some estimated mass to negative loss values near zero. That is a boundary issue rather than a weight-normalization issue; the weighted formula does not by itself remove boundary bias. Also, a common bandwidth is used throughout these calculations. If a procedure specifies observation-specific bandwidths, each contribution and its normalization must be handled according to that procedure rather than silently substituting a common-bandwidth formula.

Key takeaway: Normalize by total weight, not by the number of observations: \(\widehat f_{w,h}(x)=\sum_i(w_i/W)K((x-X_i)/h)/h\). The normalized weights sum to one, so a density kernel produces a unit-area estimate. Interpret the result in the loss units and for the exposure population represented by the weights.

Check Your Understanding

For each problem, identify the appropriate normalization and keep the loss units in mind.

  1. Losses are \(0,2,4\) thousand dollars with weights \(1,2,1\). Using a triangular kernel and \(h=2\) thousand dollars, calculate the estimate at \(x=2\). (Answer: \(0.2500\) per thousand dollars)
  2. Losses are \(1,3\) thousand dollars with weights \(3,1\). Using a triangular kernel and \(h=2\), calculate the estimate at \(x=2\). (Answer: \(0.2500\) per thousand dollars)
  3. Losses are \(0,1,3\) thousand dollars with weights \(1,2,1\). Using the Epanechnikov kernel and \(h=2\), calculate the estimate at \(x=2\). (Answer: \(27/128=0.2109\) per thousand dollars)
  4. Losses are \(4,6,10\) thousand dollars with weights \(2,3,5\). Using a triangular kernel and \(h=4\), calculate the estimate at \(x=7\). (Answer: \(0.1000\) per thousand dollars)
  5. Two hypothetical exposure groups have losses \(2\) and \(4\) thousand dollars with weights \(1\) and \(3\). Using a triangular kernel and \(h=2\), calculate the weighted estimate at \(x=4\), and compare it with the unweighted estimate. (Answer: weighted \(0.3750\), unweighted \(0.2500\), per thousand dollars)
Clinical Biostats