Missing Data, Trimming, and Winsorization in RWE
An overview of distinct operations: handling incomplete observations, restricting an analysis population, capping estimated weights, and capping outcome values. They have different consequences for identification, estimation, and interpretation and must be specified separately.
On this page
Missing records, poorly supported treatment comparisons, extreme analysis weights, and very high costs are different problems. Removing patients changes who the study describes. Capping weights keeps patients but changes their contribution and can bias the original target estimate. Capping costs changes the measured outcome. None of these operations automatically fixes missing information or confounding.
Distinct problems and operations
This entry is an overview, not a single combined method. Missingness concerns what was observed and the assumptions under which incomplete data identify the intended target. Population trimming removes records under an explicit eligibility or support rule. Weight truncation or Winsorization caps estimated analysis weights while retaining records. Outcome Winsorization caps observed outcomes such as costs. These operations must not be described as interchangeable or as automatically identifying the same newly defined target population.
Population restriction versus estimator modification
Restricting the analysis to a defined overlap region changes the population and may change the estimand to an effect in that restricted population. Re-estimate the relevant nuisance models when the method requires it and describe who was excluded. Capping inverse-probability weights generally changes the estimator's weighting and can introduce bias for the original population effect; it does not automatically identify a coherent alternative population effect. An explicit weighting scheme, such as overlap weighting, defines a different target under its own assumptions. A truncated estimator should be described in relation to its intended estimand, not relabeled as a restricted-population causal effect without justification.
Missing-data mechanisms
Missing completely at random, missing at random conditional on specified observed information, and missing not at random are assumptions about a data-generating process, not diagnoses established from a missingness table. Complete-case analysis can be valid under conditions weaker than MCAR for particular models and targets. Multiple imputation requires a compatible, adequately specified imputation/analysis strategy; departures from MAR require sensitivity analysis. Including an outcome or later observed information in a properly constructed imputation model is not automatically the same as adjusting a causal outcome model for a post-treatment variable. Respect longitudinal ordering, the substantive model, and what would be available for the actual analysis or prediction task.
Death, censoring, and observability
A clinical outcome after death may be undefined rather than an unrecorded value awaiting imputation. Choose a composite, while-alive, survivor, or other explicitly justified estimand as appropriate. In a cumulative healthcare-cost target, death can end cost accrual; it is not the same as incomplete capture after disenrollment. Disenrollment can produce dependent observation loss, but it is not inherently MNAR in every data structure. Define what is structurally impossible, what is outside the observation system, and what is missing among otherwise defined measurements. Use censoring adjustment or an explicit observation model only when the required assumptions and support are defensible.
Pros, cons, and trade-offs
Restriction can make a supported comparison more credible but reduces generalizability. Weight capping can reduce instability at the cost of bias; it cannot restore structural positivity. Outcome capping may improve numerical stability but changes the cost distribution being summarized and can discard the clinically important high-cost tail. A two-part or appropriate skewed-cost model addresses a modeling problem; it does not turn a real extreme claim into an error. Missing-data methods can use partial records but depend on assumptions not established by model convergence.
When NOT to use
Do not apply a universal maximum-weight cutoff, treat a particular effective sample size as proof of identification, or choose a cap by the most favorable treatment effect. Do not claim that trimming removes unmeasured confounding. Do not replace absent benefit coverage with zero utilization, impute undefined post-death clinical measurements as ordinary missing data, or equate absence of an EHR encounter with event-free follow-up. Do not present a capped-cost mean as the uncapped population mean. Sensitivity to an analysis choice is evidence about robustness, not by itself proof that every estimate is an artifact.
Data-source implementation
Claims require medical/pharmacy benefit observability, transaction reconciliation, and an explicit treatment of death and enrollment end. EHRs require encounter and measurement availability, dates, and outside-system-care caveats. Registries may have scheduled assessments and informative missed visits. Linked data require a linkage-selection assessment. Keep records of these decisions separate from numerical stabilization choices; a well-behaved estimator does not certify the source data.
Decision diagram
flowchart TD P["Identify the actual problem"] --> M["Incomplete observations:<br/>missingness and censoring assumptions"] P --> S["Population restriction:<br/>state new eligibility and target"] P --> W["Weight capping:<br/>bias and stability sensitivity"] P --> C["Outcome capping:<br/>state the transformed outcome"]
flowchart TD P["Identify the actual problem"] --> M["Incomplete observations:<br/>missingness and censoring assumptions"] P --> S["Population restriction:<br/>state new eligibility and target"] P --> W["Weight capping:<br/>bias and stability sensitivity"] P --> C["Outcome capping:<br/>state the transformed outcome"]
Worked example
Scenario
A pharmacoepidemiology team is estimating the average difference in one-year total cost between patients on a specialty drug (treated, T=1) and an active comparator (T=0). They fit a logistic model to get a propensity score for each patient, then compute stabilized inverse-probability weights. The marginal probability of being treated is 3/6 = 0.50, so the stabilized weight for each treated patient is 0.50 divided by their propensity score, and for each comparator patient is 0.50 divided by (1 minus their propensity score). Inspecting the weights reveals two patients — one in each arm — with a propensity score near the boundary of their group, producing a weight of 10.0. Those two patients together hold most of the total weight in the analysis. The team pre-specified a rule: compare trimming (drop patients with weight above 5.0) versus winsorizing (cap weights above 5.0 at 5.0), and report both alongside the raw result.
Dataset
Analysis-ready table: one row per patient with propensity score, stabilized weight, and one-year total cost in thousands of dollars.
| patient_id | arm | propensity_score | stabilized_weight | total_cost_k |
|---|---|---|---|---|
| P01 | treated | 0.8 | 0.625 | 18 |
| P02 | treated | 0.4 | 1.25 | 22 |
| P03 | treated | 0.05 | 10.0 | 45 |
| P04 | comparator | 0.2 | 0.625 | 12 |
| P05 | comparator | 0.6 | 1.25 | 10 |
| P06 | comparator | 0.95 | 10.0 | 8 |
Steps
Result
Raw weighted cost difference is approximately $32,740; dropping records with estimated weight above 5 gives approximately $10,000 in the remaining four records; capping weights at 5 gives approximately $29,640 while retaining six records. These are sensitivity analyses. Dropping on estimated weight changes the analyzed sample but does not by itself identify a prespecified overlap-population causal effect. A primary restricted-population estimand needs its own justified eligibility/support rule. Capping modifies the estimator and can bias the original target. None of these synthetic descriptive calculations establishes a causal cost effect.
Trade-offs
Code example
Execution not verified · inspect inputs and dependencies before use
Operationalize stabilized IPTW with diagnostics, then apply (a) symmetric PS trimming and (b) percentile Winsorization, reporting effective sample size for each rule. Required input (one row per person, already cleaned): df : person_id, treat (1/0 study vs comparator), ps (estimated propensity, 0<ps<1), y (outcome,...
import numpy as np
import pandas as pd
def stabilized_iptw(df: pd.DataFrame) -> pd.Series:
"""Stabilized inverse-probability-of-treatment weights (Austin & Stuart 2015)."""
p_treat = df["treat"].mean()
w = np.where(df["treat"] == 1, p_treat / df["ps"], (1 - p_treat) / (1 - df["ps"]))
return pd.Series(w, index=df.index)
def effective_sample_size(w: pd.Series) -> float:
"""Kish ESS: collapses as a few weights dominate."""
return (w.sum() ** 2) / (w ** 2).sum()
def symmetric_ps_trim(df: pd.DataFrame, lo: float = 0.01, hi: float = 0.99) -> pd.DataFrame:
"""Stürmer-style trim on percentiles of the TREATED-arm PS, then keep the overlap region."""
ps_t = df.loc[df["treat"] == 1, "ps"]
lo_cut, hi_cut = ps_t.quantile(lo), ps_t.quantile(hi)
return df[(df["ps"] >= lo_cut) & (df["ps"] <= hi_cut)].copy()
def winsorize(s: pd.Series, lo: float = 0.01, hi: float = 0.99) -> pd.Series:
return s.clip(lower=s.quantile(lo), upper=s.quantile(hi))
def weighted_mean_diff(df: pd.DataFrame, w: pd.Series) -> float:
"""Weighted ATE-style contrast of y between arms (e.g., cost difference)."""
t = df["treat"] == 1
m1 = np.average(df.loc[t, "y"], weights=w[t])
m0 = np.average(df.loc[~t, "y"], weights=w[~t])
return m1 - m0
# --- Sensitivity grid: no-trim vs symmetric trim, crossed with no-Winsor vs 99th-pct Winsor ---
rows = []
for trim_name, d in [("no_trim", df), ("trim_1_99", symmetric_ps_trim(df))]:
w = stabilized_iptw(d) # recompute weights AFTER trimming
for win_name, yy in [("no_winsor", d["y"]), ("winsor_99", winsorize(d["y"]))]:
dd = d.assign(y=yy.values)
rows.append({
"trim": trim_name, "winsor": win_name,
"n": len(dd), "ess": round(effective_sample_size(w), 1),
"pct_trimmed": round(100 * (1 - len(dd) / len(df)), 2),
"max_weight": round(float(w.max()), 1),
"effect": round(weighted_mean_diff(dd, w), 2),
})
print(pd.DataFrame(rows))Execution not verified · inspect inputs and dependencies before use
Same sensitivity engine in R: stabilized IPTW with effective sample size, symmetric PS trimming (recompute weights after trimming), and percentile Winsorization, reported as a grid. Input analysis-ready data frame: df : person_id, treat (1/0), ps (0<ps<1), y (outcome)
library(data.table)
stabilized_iptw <- function(d) {
p <- mean(d$treat)
ifelse(d$treat == 1L, p / d$ps, (1 - p) / (1 - d$ps))
}
ess <- function(w) sum(w)^2 / sum(w^2) # Kish effective sample size
symmetric_ps_trim <- function(d, lo = 0.01, hi = 0.99) {
q <- quantile(d$ps[d$treat == 1L], probs = c(lo, hi))
d[d$ps >= q[1] & d$ps <= q[2]]
}
winsorize <- function(x, lo = 0.01, hi = 0.99) {
q <- quantile(x, probs = c(lo, hi)); pmin(pmax(x, q[1]), q[2])
}
wmean_diff <- function(d, w) {
t <- d$treat == 1L
weighted.mean(d$y[t], w[t]) - weighted.mean(d$y[!t], w[!t])
}
build_grid <- function(df) {
setDT(df)
out <- list()
for (tn in c("no_trim", "trim_1_99")) {
d <- if (tn == "no_trim") copy(df) else symmetric_ps_trim(df)
w <- stabilized_iptw(d) # recompute AFTER trimming
for (wn in c("no_winsor", "winsor_99")) {
yy <- if (wn == "no_winsor") d$y else winsorize(d$y)
dd <- copy(d)[, y := yy]
out[[paste(tn, wn)]] <- data.table(
trim = tn, winsor = wn, n = nrow(dd),
ess = round(ess(w), 1),
pct_trimmed = round(100 * (1 - nrow(dd) / nrow(df)), 2),
max_weight = round(max(w), 1),
effect = round(wmean_diff(dd, w), 2)
)
}
}
rbindlist(out)
}
print(build_grid(df))Execution not verified · inspect inputs and dependencies before use
SAS implementation: estimate the PS with PROC PSMATCH (or PROC LOGISTIC), build stabilized IPTW, apply symmetric PS trimming and percentile Winsorization, and fit the weighted outcome model with PROC GENMOD.
/* 1. Propensity score from baseline covariates (logit link). */
proc logistic data=work.analytic descending noprint;
class <categorical covariates>;
model treat = <baseline covariates>;
output out=ps_out pred=ps; /* ps = P(treat=1 | covariates) */
run;
/* 2. Stabilized IPTW (Austin & Stuart 2015). */
proc sql noprint;
select mean(treat) into :ptreat trimmed from work.analytic;
quit;
data wts;
set ps_out;
if treat=1 then sw = &ptreat / ps;
else sw = (1-&ptreat) / (1-ps);
run;
/* 3. Symmetric PS trim on the 1st/99th percentiles of the TREATED-arm PS. */
proc univariate data=wts(where=(treat=1)) noprint;
var ps;
output out=cuts pctlpts=1 99 pctlpre=ps_;
run;
data trimmed;
if _n_=1 then set cuts; /* ps_1, ps_99 */
set wts;
if ps_1 <= ps <= ps_99; /* keep overlap region; weights recomputed below */
run;
/* 4. Recompute stabilized weights on the trimmed cohort. */
proc sql noprint;
select mean(treat) into :ptrim trimmed from trimmed;
quit;
data trimmed;
set trimmed;
if treat=1 then sw = &ptrim / ps; else sw = (1-&ptrim) / (1-ps);
run;
/* 5. Winsorize the outcome at the 99th percentile (sensitivity layer). */
proc univariate data=trimmed noprint;
var y; output out=ycut pctlpts=99 pctlpre=y_;
run;
data trimmed_w;
if _n_=1 then set ycut; /* y_99 */
set trimmed;
y_win = min(y, y_99);
run;
/* 6. Weighted outcome model (gamma-log GLM for skewed cost; swap dist=/link= as needed). */
proc genmod data=trimmed_w;
class person_id;
weight sw;
model y_win = treat / dist=gamma link=log;
repeated subject=person_id / type=ind; /* robust SEs for the weighted estimator */
estimate 'treat vs comparator (log scale)' treat 1 / exp;
run;Citations
- [1]Stürmer T, Rothman KJ, Avorn J, Glynn RJ. Treatment effects in the presence of unmeasured confounding: dealing with observations in the tails of the propensity score distribution--a simulation study. American Journal of Epidemiology. 2010;172(7):843-854.
- [2]Crump RK, Hotz VJ, Imbens GW, Mitnik OA. Dealing with limited overlap in estimation of average treatment effects. Biometrika. 2009;96(1):187-199.