Why Estimate a Conditional Density?
For a continuous treatment, the probability of receiving exactly the observed dose is typically zero. The relevant treatment mechanism is therefore a density, not a point probability. In inverse probability weighting, the density at the observed dose is compared with a numerator density, often the marginal treatment density. Kernel estimation offers a flexible way to estimate that conditional density when a convenient parametric form is doubtful.
Let \(A\) be a scalar continuous treatment and let \(L\) be a vector of \(d\) covariates measured before treatment assignment. Write \(f_{A\mid L}(a\mid l)\) for the conditional density of treatment at dose \(a\), given covariate value \(l\). The objective here is to estimate this density locally from observed pairs \((A_i,L_i)\), then evaluate it at each person’s observed \((A_i,L_i)\). A small estimated density at an observed dose can produce a large inverse density weight.
Constructing the Estimator
Suppose \((A_i,L_i)\), \(i=1,\ldots,n\), are independent observations from a common distribution. Use a one-dimensional kernel \(K_A\) for treatment and a product kernel \(\mathcal K_L(u)=\prod_{j=1}^{d}K_L(u_j)\) for the covariates. Assume each kernel is nonnegative, integrates to one, and is bounded. Let \(h_A>0\) and \(h_L>0\) be their bandwidths. A joint density estimate and a covariate density estimate are
Dividing the joint estimate by the covariate estimate gives the conditional estimate, wherever the denominator is positive:
The second expression shows the local averaging directly. Each covariate-near observation receives a kernel weight, and its treatment contributes a smoothed density value \(K_A((A_i-a)/h_A)/h_A\). The estimator is a density in the treatment scale, so its units are inverse dose units.
For an inverse density weight with marginal treatment density as numerator, the plug-in estimate at subject \(i\)’s observed dose is
Both densities in the ratio have the same units, so the weight is dimensionless. This tutorial focuses on estimating and evaluating the conditional density; it does not change the interpretation of density-ratio weights established in the earlier material on continuous-treatment weights.
Worked Example: Estimating a Conditional Density and Weight
Use the uniform kernel \(K(u)=1/2\) for \(|u|\leq 1\), and \(K(u)=0\) otherwise. There is one covariate, and the four observations are \((A,L)=(1.8,1.0),(2.1,1.5),(1.2,0.4),(2.4,1.1)\). Estimate the conditional density at the observed dose and covariate value of the fourth observation, \((a,l)=(2.4,1.1)\), using \(h_A=0.5\) and \(h_L=0.5\).
The covariate kernel is nonzero when \(|L_i-1.1|\leq 0.5\). The four covariate distances are \(0.1,0.4,0.7,0\), so observations 1, 2, and 4 contribute, each with kernel value \(1/2\). Among those three, the treatment kernel is nonzero when \(|A_i-2.4|\leq 0.5\). Observations 2 and 4 qualify; their treatment-kernel values are also \(1/2\).
The denominator of the conditional estimator is \(h_A\) times the sum of the three covariate-kernel values: \(0.5(3/2)=0.75\). The numerator is the sum of the two nonzero products, \(2(1/2)(1/2)=0.5\). Therefore,
For the marginal estimate at \(2.4\), only doses \(2.1\) and \(2.4\) fall within the treatment-kernel window. Each contributes \((1/2)/0.5=1\), and the estimate divides their sum by \(n=4\): \(\widehat f_A(2.4)=2/4=0.5\). The estimated density-ratio weight is \(0.5/(2/3)=0.75\). This is an illustration of the plug-in calculation, not evidence that the estimate is stable: it is based on only three covariate-near observations.
Pointwise Consistency
Kernel smoothing is useful only if it can recover the target conditional density as the sample grows and the neighborhoods shrink. The following pointwise result states sufficient conditions. It concerns an interior point \((a,l)\) where the joint density \(f_{A,L}\) and marginal covariate density \(f_L\) are continuous, with \(f_L(l)>0\).
Proof. First consider the joint density estimate. A change of variables in its expectation expresses it as an average of \(f_{A,L}\) over a shrinking kernel neighborhood of \((a,l)\). Because the kernels integrate to one, have compact support, and the density is continuous at that point,
The same argument gives \(E[\widehat f_L(l)]\to f_L(l)\). Bounded kernels and locally bounded densities give variance orders \(O((n h_A h_L^d)^{-1})\) for the joint estimate and \(O((n h_L^d)^{-1})\) for the covariate estimate. The first variance tends to zero by the bandwidth condition. The second does too, since \(n h_L^d=(n h_A h_L^d)/h_A\to\infty\). Thus both estimates converge in probability to their respective densities. Since \(f_L(l)>0\), the denominator converges to a positive value, so the ratio converges in probability to \(f_{A,L}(a,l)/f_L(l)=f_{A\mid L}(a\mid l)\), by the continuous mapping theorem. \(\square\)
This is a pointwise large-sample result, not a guarantee of good finite-sample weights. It does not apply automatically at support boundaries, where symmetric kernels can place mass outside the treatment’s possible range. Nor does it rescue a covariate neighborhood with too few observations in a particular data set.
Bandwidths, Local Support, and Diagnostics
A smaller bandwidth emphasizes observations close to the evaluation point. This can capture sharp changes in the treatment density, but it also makes the estimate more variable and can leave the denominator nearly zero. A larger bandwidth stabilizes the estimate by borrowing information from farther away, at the cost of smoothing over real differences in treatment distributions across covariate values. The treatment and covariate bandwidths control distinct kinds of smoothing and should not be treated as interchangeable.
A practical diagnostic is to inspect the covariate-kernel contributions near each evaluated \(L_i\), along with the treatment-kernel contributions near \(A_i\). For normalized covariate contributions \(q_j(l)\), where \(q_j(l)\) is each nonnegative covariate-kernel weight divided by their sum, the effective local sample size is \(1/\sum_j q_j(l)^2\). It is close to the actual number of equally weighted observations when contributions are similar, and falls when a few observations dominate. A zero covariate-kernel sum makes the conditional estimate undefined. A very small treatment density at an observed dose can instead yield an extreme weight even when the covariate denominator is nonzero.
Worked Example: How a Covariate Bandwidth Changes the Estimate
Return to the four observations in the first example and the target \((2.4,1.1)\). Keep the uniform treatment kernel and \(h_A=0.5\), but increase the covariate bandwidth from \(0.5\) to \(1.0\). All four covariate values now fall within distance \(1.0\) of \(1.1\), so the covariate-kernel sum is \(4(1/2)=2\). Only doses \(2.1\) and \(2.4\) remain within \(0.5\) of the target dose, so the numerator is still \(2(1/2)(1/2)=0.5\).
The conditional estimate is now \(0.5/[0.5(2)]=0.5\), rather than \(2/3\). The marginal estimate remains \(0.5\), because neither its data nor its treatment bandwidth changed. The estimated weight therefore changes from \(0.5/(2/3)=0.75\) to \(0.5/0.5=1\). Broadening the covariate neighborhood added an observation whose dose was not near \(2.4\); it lowered the estimated conditional density at that dose and changed the weight.
Worked Example: Detecting Concentration in a Local Neighborhood
Suppose three observations have covariate-kernel contributions \(0.8,0.1,0.1\) at a particular \(l\). Their normalized contributions are the same numbers because they sum to one. The effective local sample size is
Although three observations contribute, the local estimate behaves as if roughly one and a half equally weighted observations were available. This warns that the conditional density may be sensitive to individual records and the bandwidth. If the dose-kernel contribution at the target is also supported by just one record, the estimate may be especially unstable. A nonzero denominator alone is not a sufficient diagnostic of adequate local information.
When reviewing fitted weights, examine the estimated conditional densities and weight distribution rather than reporting only an average. Look for near-zero density estimates, very large weights, observations with no covariate neighbors, and strong changes under reasonable bandwidth choices. These patterns indicate weak local support or excessive smoothing sensitivity. Extreme weights are not automatically proof of an implementation error, but they flag a region where the data provide limited information about comparable treatment assignments.
Alternatives and Limits
A parametric conditional density model, such as a Gaussian, Gamma, or Beta model when appropriate to the dose scale, can be more stable in sparse data and gives a compact description of the treatment mechanism. Its risk is model misspecification: an incorrect shape or covariate relationship can distort density estimates at observed doses. A kernel estimate avoids committing to that particular parametric shape, but it needs sufficient local data and depends on bandwidth choices. It can perform poorly with many covariates because nearby observations become sparse in high-dimensional covariate space. These approaches are alternatives, not guarantees against weak overlap.
Kernel estimates also require special care near the edges of a treatment’s support. A symmetric kernel centered near a boundary allocates some smoothing mass outside the feasible range, potentially biasing the estimate. The estimate may even assign density where the treatment cannot occur. Diagnose boundary proximity and implausible fitted values; do not interpret smoothing as creating genuine support. Transforming the treatment and correcting the resulting density is a separate issue addressed in the material on Jacobian corrections.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions below.
- In the joint-over-marginal construction, why does the covariate bandwidth scaling cancel from the conditional estimator?
- A conditional density estimate at an observed dose is \(0.25\), and the estimated marginal treatment density there is \(0.50\). What is the plug-in density-ratio weight?
- What does a zero sum of covariate-kernel contributions imply at an evaluation point?
- Why can increasing the covariate bandwidth change a conditional density estimate even when the treatment bandwidth is held fixed?
- Name one limitation of the pointwise consistency result near a treatment boundary.
Solutions. (1) Both the joint estimate and the marginal covariate estimate contain the same factor \(1/(n h_L^d)\); it cancels in their ratio, leaving the treatment scaling \(1/h_A\). (2) The weight is \(0.50/0.25=2\). (3) The conditional estimator is undefined because it has no covariate-near observations to form its denominator. (4) A larger covariate bandwidth changes which observations contribute, and how strongly, to the local treatment estimate. (5) Symmetric smoothing at a boundary can include points outside the feasible support, so the interior-point continuity and smoothing argument does not directly establish the same behavior there.