Tutorials › Multivariate Statistics (Graduate) › Density-Ratio Estimation and Overlap Diagnostics

Discriminant Inference and Risk · Tutorial 626 of 975

Density-Ratio Estimation and Overlap Diagnostics

Estimate covariate-shift weights from a domain classifier, then assess how much the resulting weighted analysis depends on weak overlap and extreme weights.

Advanced 12 min read

What You'll Learn

  • Define the target-to-source density ratio and the support condition needed for weighting.
  • Derive density-ratio estimates from pooled-sample domain-classifier probabilities.
  • Calculate effective sample size and interpret it alongside the weight distribution.
  • Diagnose regions where target observations have weak source representation.
  • Quantify how truncating large weights changes a weighted estimate.
  • Distinguish evidence of poor overlap from evidence that overlap is adequate.

Why Estimate a Density Ratio?

Under covariate shift, a source sample and a target population have different covariate distributions, while the conditional distribution of the outcome given the covariates is assumed to remain the same. Importance-weighted risk uses source observations to represent the target covariate distribution. Its central weight is therefore the target-to-source covariate density ratio. Estimating this ratio is not just a computational step: large or unstable weights can reveal that the source data provide little information about parts of the target population.

Let \(X\) denote the covariates, with source distribution \(P_s\) and target distribution \(P_t\). When both have densities with respect to a common measure, write them as \(f_s(x)\) and \(f_t(x)\). The ratio is defined only where the source distribution can represent the target distribution.

Definition: The target-to-source density ratio is \(r(x)=f_t(x)/f_s(x)\) wherever \(f_s(x)>0\). More generally, it is the Radon–Nikodym derivative \(dP_t/dP_s\), which exists when \(P_t\) is absolutely continuous with respect to \(P_s\). This condition, \(P_t\ll P_s\), means every set with zero source probability also has zero target probability. It is the support or overlap condition needed for exact source-to-target weighting.

If \(P_t\ll P_s\) and \(g(X)\) is integrable under the target distribution, the change-of-measure identity is

$$ E_t[g(X)] = E_s[r(X)g(X)]. $$

Indeed, in the density case, \(E_s[r(X)g(X)]=\int [f_t(x)/f_s(x)]g(x)f_s(x)\,dx=\int g(x)f_t(x)\,dx=E_t[g(X)]\). The identity explains why source observations receive weights \(r(X)\), and why a very large ratio can make an estimate sensitive to a few observations.

Estimating Ratios With a Domain Classifier

A practical approach is to pool source and target covariates and predict which sample an observation came from. Define a domain label \(D=1\) for a target observation and \(D=0\) for a source observation. Let \(\pi_t=P(D=1)\) and \(\pi_s=P(D=0)\) be the proportions in the pooled population. Write \(q(x)=P(D=1\mid X=x)\). Bayes' rule gives a direct relationship between domain-classification probabilities and the density ratio.

Result: If the pooled samples are drawn from source and target covariate distributions with proportions \(\pi_s\) and \(\pi_t\), then, wherever the relevant densities are positive, \(q(x)/(1-q(x))=(\pi_t/\pi_s)r(x)\). Thus \(r(x)=(\pi_s/\pi_t)q(x)/(1-q(x))\).

To verify the relationship, the joint densities for the two domain labels are \(\pi_t f_t(x)\) and \(\pi_s f_s(x)\). Therefore

$$ q(x)=\frac{\pi_t f_t(x)} {\pi_t f_t(x)+\pi_s f_s(x)},\qquad 1-q(x)=\frac{\pi_s f_s(x)} {\pi_t f_t(x)+\pi_s f_s(x)}. $$

Dividing the first expression by the second gives the stated odds identity. With \(n_t\) target and \(n_s\) source observations, the sample proportions are typically \(\pi_t=n_t/(n_s+n_t)\) and \(\pi_s=n_s/(n_s+n_t)\). Hence the multiplier \(\pi_s/\pi_t\) is \(n_s/n_t\). Omitting it generally gives ratios on the wrong scale.

A fitted logistic regression is one way to estimate \(q(x)\); a more flexible classifier may be used when the relationship is nonlinear. The odds transformation is reliable only to the extent that the estimated domain probabilities are reliable, particularly in their tails. Probabilities near one produce very large estimated ratios. Use held-out or cross-fitted domain predictions when feasible, and examine calibration as well as classification performance: accurate domain labels do not by themselves guarantee accurate probability estimates.

Worked Example: Recovering the Ratio From Domain Odds

Suppose a pooled data set contains \(n_s=200\) source observations and \(n_t=100\) target observations. For a covariate value \(x_1\), a fitted domain model gives \(\hat q(x_1)=0.20\). For \(x_2\), it gives \(\hat q(x_2)=0.60\). Calculate the implied density-ratio estimates.

The sample proportions are \(\pi_s=200/300=2/3\) and \(\pi_t=100/300=1/3\), so \(\pi_s/\pi_t=2\). At \(x_1\), the domain odds are \(0.20/(1-0.20)=0.20/0.80=0.25\). Therefore \(\hat r(x_1)=2(0.25)=0.50\). The target density is estimated to be half the source density there.

At \(x_2\), the odds are \(0.60/(1-0.60)=0.60/0.40=1.5\), so \(\hat r(x_2)=2(1.5)=3\). The target density is estimated to be three times the source density at \(x_2\). The inverse ratio would answer a different question and would not be the weight for reweighting source observations toward the target.

Overlap Diagnostics and Effective Sample Size

The overlap condition is a population statement, but available data can only reveal warning signs. Inspect the estimated weights on source observations: their histogram or quantiles, the largest values, and the fraction of total weight carried by the largest few observations. Also compare source and target covariates or domain scores to identify regions that appear in the target sample but are rare in the source sample. These checks are complementary: a single summary cannot establish that all target-relevant regions are represented.

For positive weights \(w_1,\ldots,w_n\), the weight-based effective sample size is

$$ \operatorname{ESS} = \frac{\left(\sum_{i=1}^n w_i\right)^2} {\sum_{i=1}^n w_i^2}. $$

This number summarizes weight concentration. It equals \(n\) if all weights are equal, and decreases as weight is concentrated in fewer observations. It is a diagnostic, not a guarantee that the weighted estimator has the precision of an independent sample of that size.

Result: For nonnegative weights with at least one positive value, \(1\leq\operatorname{ESS}\leq n\). The upper bound is attained when all weights are equal; the lower bound is attained when exactly one weight is positive.

For the upper bound, Cauchy–Schwarz gives \((\sum_i w_i)^2\leq n\sum_i w_i^2\), and division by the positive denominator yields \(\operatorname{ESS}\leq n\). For the lower bound, expanding the square gives \((\sum_i w_i)^2=\sum_i w_i^2+2\sum_{i<j}w_iw_j\geq\sum_i w_i^2\), so \(\operatorname{ESS}\geq1\). Equality in the upper bound requires equal weights; equality in the lower bound requires all pairwise products to be zero, so at most one weight is positive. \(\square\)

Worked Example: A Small Effective Sample Size

A source sample contains ten observations: five with weight \(0.4\), three with weight \(1\), and two with weight \(2.5\). Calculate the effective sample size and identify the main source of concentration.

The sum of the weights is \(5(0.4)+3(1)+2(2.5)=2+3+5=10\). The sum of squared weights is \(5(0.4^2)+3(1^2)+2(2.5^2)=5(0.16)+3+2(6.25)=0.8+3+12.5=16.3\). Therefore

$$ \operatorname{ESS}=\frac{10^2}{16.3}\approx 6.13. $$

The nominal sample size is ten, but the weights have the concentration of roughly six equally weighted observations by this summary. The two observations with weight \(2.5\) contribute \(12.5/16.3\approx0.767\), or about 77% of the sum of squared weights. That concentration is a reason to inspect those observations and their covariate region, not a reason to discard them automatically.

Truncation: Stability at a Cost

A common response to extreme estimated weights is truncation. At a threshold \(c>0\), replace \(r(x)\) by \(r_c(x)=\min\{r(x),c\}\). This caps the influence of individual observations, but it changes the weighting scheme. For a target quantity \(E_t[g(X)]\), the unnormalized truncated expectation has an exact discrepancy:

$$ E_s[r(X)g(X)]-E_s[r_c(X)g(X)] = E_s[(r(X)-c)_+g(X)], $$

where \((u)_+=\max(u,0)\). This follows pointwise from \(r-r_c=(r-c)_+\), followed by taking expectations. If \(0\leq g\leq1\), the absolute discrepancy is at most \(E_s[(r-c)_+]\). The bound shows why the mass and size of the tail above the cutoff matter. If truncated weights are then normalized to sum to one, the resulting estimate targets a normalized, altered weighting distribution; it is not simply the unnormalized expression above.

Worked Example: How a Weight Cap Changes the Estimate

Consider four covariate categories \(A,B,C,D\). Their source probabilities are \(0.4,0.3,0.2,0.1\), and their true ratios are \(0.375,0.5,1,5\). Check that these ratios define a target distribution, then estimate the target probability of category \(D\) after capping weights at \(c=2\) and normalizing.

The target probabilities are the source probabilities multiplied by their ratios: \(0.4(0.375)=0.15\), \(0.3(0.5)=0.15\), \(0.2(1)=0.20\), and \(0.1(5)=0.50\). They sum to \(0.15+0.15+0.20+0.50=1\), as required. Thus the true target probability of \(D\) is \(0.50\).

After capping, the four weights are \(0.375,0.5,1,2\). Their source-weighted total is \(0.4(0.375)+0.3(0.5)+0.2(1)+0.1(2)=0.15+0.15+0.20+0.20=0.70\). The normalized truncated estimate of the probability of \(D\) is \(0.1(2)/0.70=0.20/0.70\approx0.286\), well below the true value \(0.50\). The cap reduces the contribution of a target-important category because its source observations carry the largest ratio.

For this example, the unnormalized lost contribution for the indicator \(g=1\{X=D\}\) is \(0.1(5-2)=0.30\). The discrepancy between the true unnormalized target probability, \(0.50\), and its truncated unnormalized value, \(0.20\), is exactly \(0.30\). Normalization changes the numerical comparison further.

A Practical Diagnostic Sequence

The most useful assessment combines weight summaries with direct inspection of the covariate regions that generate high ratios. A large weight can indicate genuine target mass in a source-rare region, estimation error in the domain model, or both. Compare estimates under several pre-specified caps, and report the cap, the fraction of observations affected, the resulting ESS, and how the substantive estimate changes. A stable estimate across reasonable choices is reassuring but does not prove overlap; a sharp change is evidence that the conclusion depends on the tail of the weighting distribution.

1
Estimate the ratio.
Fit a domain-probability model using source and target covariates, account for the sampling proportions, and obtain out-of-sample probability estimates where feasible.
2
Inspect support and weights.
Examine the weight distribution and covariate regions with high estimated target-to-source odds; look for target observations with little apparent source representation.
3
Assess concentration and sensitivity.
Compute ESS and compare the untruncated analysis with clearly reported truncation choices, including the change in the estimate.

Common mistake: “The ESS is close to the source sample size, so overlap must be adequate.” This reasoning is not valid. ESS is computed from the estimated weights on observed source cases; it cannot detect target regions absent from both the source sample and the fitted model’s effective view of the covariate space. Conversely, a low ESS is a warning about concentration, not proof that the ratio model is wrong. Use ESS together with support and covariate diagnostics, and state that empirical checks cannot certify population-level overlap.

Another mistake is to treat truncation as a harmless numerical repair. Capping weights can reduce variance, but it also changes the represented target distribution. The appropriate report makes this trade-off visible rather than presenting the capped result as if it were an exact target-weighted estimate.

Key takeaway: Density-ratio estimates turn source observations into target-relevant weights only when the target is represented by the source. Domain odds provide a practical estimator, while weight tails, ESS, and truncation sensitivity diagnose how fragile that representation may be. No one diagnostic replaces the others.

Check Your Understanding

Answer each question using the definitions and calculations above.

  1. What support condition is needed for the target-to-source density ratio to exist, and why does it matter for weighted estimation?
  2. A pooled sample has 150 source and 50 target observations. A domain model gives \(\hat q(x)=0.4\). What density ratio does the domain-odds identity imply?
  3. Why can a high domain-classification accuracy be insufficient evidence that estimated density ratios are reliable?
  4. What does a low effective sample size indicate, and what does it not establish?
  5. Why does truncating large weights change the weighted target estimate? Distinguish the unnormalized and normalized cases.
Clinical Biostats