What These Plots Can Show
A boxplot compresses a distribution into its median, quartiles, and potential outliers. A violin plot uses a smoothed density estimate to show where values are concentrated. In an imputation diagnostic, the two groups are typically observed values and values imputed for missing entries of the same variable. Used together, the plots can reveal a shifted center, a different spread, an unusual tail, or an apparent change in shape.
These displays are diagnostic summaries, not tests of whether the imputation model is correct. In particular, the observed cases and the cases with missing values need not have the same distribution. If missingness depends on measured predictors, the two groups can differ marginally even when imputations are appropriate. The earlier material on density plots, quantile plots, and empirical CDFs provides other distributional comparisons; here the emphasis is on what box and violin displays communicate, and where their compression or smoothing can mislead.
Quartile definitions can differ slightly across software, especially for small samples. A careful comparison uses the same quartile convention and plotting settings for both groups. The 1.5-IQR fences flag values for display; they are not hypothesis tests and do not establish that a flagged observation is erroneous.
Reading the Boxplot
The median marks the center in the sense of the 50th percentile. The box extends from \(Q_1\) to \(Q_3\), so its length represents the middle half of the values. Whiskers and points provide some information about the tails, but the whiskers do not generally show the minimum and maximum when values lie beyond the fences. A boxplot also does not show all features of a distribution: for example, two groups can have similar quartiles while differing in multimodality or in detail within the tails.
Worked Example: Comparing Centers and Spreads
Suppose a hypothetical diagnostic compares eight observed values, in units of mg/L, with eight imputed values from one completed data set. The observed values are \(10, 11, 12, 12, 13, 14, 15, 16\); the imputed values are \(9, 10, 11, 12, 12, 13, 14, 15\). Use the median-of-halves quartile convention.
For the observed values, the median is \((12+13)/2=12.5\) mg/L. The lower half is \(10,11,12,12\), so \(Q_1=(11+12)/2=11.5\) mg/L. The upper half is \(13,14,15,16\), so \(Q_3=(14+15)/2=14.5\) mg/L. Thus \(IQR=14.5-11.5=3.0\) mg/L. The fences are \(11.5-1.5(3.0)=7.0\) and \(14.5+1.5(3.0)=19.0\) mg/L. All eight values lie within them, so the whiskers reach 10 and 16 mg/L.
For the imputed values, the median is \((12+12)/2=12.0\) mg/L. The lower half \(9,10,11,12\) gives \(Q_1=10.5\) mg/L; the upper half \(12,13,14,15\) gives \(Q_3=13.5\) mg/L. The \(IQR\) is again \(3.0\) mg/L, and the fences are 6.0 and 18.0 mg/L. The whiskers reach 9 and 15 mg/L.
In this small hypothetical comparison, the imputed median is 0.5 mg/L lower, while the interquartile ranges are equal. The plotted summaries do not show a dramatic spread difference, but they cannot establish that the imputation model is adequate. The sample sizes are small, and the observed and imputed cases may differ in their predictor distributions.
Reading the Violin and Choosing the Comparison
A violin’s width represents estimated density, not the number of observations at that exact value. One common kernel density estimate for values \(y_1,\ldots,y_n\) is
where \(K\) is a kernel function and \(h\) is a bandwidth controlling the amount of smoothing. Larger bandwidths smooth over more local detail; smaller bandwidths can create a bumpy display. Software may scale violins to equal maximum width or to reflect sample size, so widths across groups should be interpreted using the stated scaling convention. A median or quartile marker inside a violin can help connect its shape to familiar summaries, but it does not remove the effects of smoothing.
For an observed-versus-imputed comparison, first establish what each group contains. With multiple imputations, a display for one completed data set can be compared with a display from another, or imputed draws can be summarized across completed data sets using a clearly stated rule. Simply concatenating all imputed values is not equivalent to collecting independent observations: the same missing cases recur across imputations, and each data set is a draw from the imputation procedure. Such pooling can make a plot look more stable than the underlying information warrants. For diagnostics across iterations or chains, retaining separate displays can help reveal instability that a pooled plot would conceal.
Worked Example: A Marginal Difference Can Reflect Case Composition
Consider hypothetical observed values and imputed values in two predictor-defined strata, A and B. In stratum A, observed values are \(2,3,4\) and imputed values are \(2,3,3,4,4\). In stratum B, observed values are \(8,9,10\) and the imputed value is \(8\). All values are in the same measurement units.
The observed pooled values are \(2,3,4,8,9,10\). Their median is \((4+8)/2=6\). The imputed pooled values are \(2,3,3,4,4,8\), with median \((3+4)/2=3.5\). A pooled boxplot therefore shows a substantially lower imputed median.
The stratum-specific comparison gives a different view. In stratum A, the observed median is 3 and the imputed median is 3; the values occupy a similar range. In stratum B, the observed median is 9 and the single imputed value is 8. That one imputed value cannot reliably characterize the stratum’s center or spread. The pooled discrepancy is consistent with different proportions of A and B among the observed and missing cases, rather than proving that the imputation model is wrong.
This example does not establish that the imputations are appropriate: the stratum B evidence is especially sparse, and these are only a few values. It demonstrates why a marginal plot should be interpreted alongside the variables that predict missingness and the outcome. When scientifically relevant predictors define distinct groups, stratified displays can help distinguish a composition difference from a within-stratum discrepancy.
Small Samples and Smoothing
With few values, quartiles and violin shapes are both uncertain summaries. A boxplot can hide the individual observations and make the box appear more precise than the sample supports; displaying points alongside it can make the available information clearer. A violin estimated from a small sample is particularly sensitive to bandwidth and boundary behavior. A smooth bulge is not evidence of a real mode, and a narrow neck is not evidence of a genuine gap.
The following calculation illustrates how a single isolated value can affect a violin. Suppose the hypothetical values are \(1,1,2,5\), and use a Gaussian kernel with bandwidth \(h=1\). The standard normal density has \(\phi(0)\approx0.3989\), \(\phi(1)\approx0.2420\), and \(\phi(4)\approx0.0001\). At \(y=1\), the estimated density is
The estimate is in inverse units of the measurement. The two repeated values contribute two kernel peaks centered at 1, while the isolated 5 contributes a small amount there. A different bandwidth would change the apparent width and shape. With only four values, the resulting curve is a visualization choice applied to sparse data, not a well-supported account of the population distribution.
Assumptions, Diagnostics, and Alternatives
A sound comparison begins with a well-defined variable, a consistent measurement scale, and correctly separated observed and imputed entries. If values are pooled across imputations, the pooling rule and the repeated appearance of missing cases must be considered. Interpreting observed and imputed distributions as if they should match additionally requires justification: it may be reasonable as a rough check in some settings, but it is not a general consequence of a correctly specified imputation model. Under missing at random, missingness may depend on observed predictors, so the marginal distribution among cases with missing values can differ from that among observed cases.
Use the plot as a prompt for investigation. Look for a median or box shift, a change in IQR, asymmetric whiskers, potential outliers, and—when sample size supports it—features in the violin’s shape. Then ask whether the difference is plausible given predictor composition, the imputation model, and the amount of information available. A striking discrepancy may indicate a modeling or data-processing problem, but visual agreement cannot verify the assumptions that generated the imputations.
Boxplots are compact and comparatively insensitive to smoothing choices, but discard much of the distribution’s detail. Violins reveal more about estimated shape, but depend on density estimation and can overstate structure in sparse data. Dot plots expose individual values when samples are small; density plots, quantile plots, and empirical CDFs offer other views of distributional differences. No single display resolves all diagnostic questions.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- A boxplot has \(Q_1=20\) units and \(Q_3=28\) units. Calculate the IQR and the 1.5-IQR fences. What do values beyond the fences indicate?
- Observed cases have a higher marginal median than imputed cases, but the observed cases contain more members of a high-outcome predictor stratum. Does this alone establish a faulty imputation model? Explain.
- A violin plot from six values shows two narrow peaks. What should you check before interpreting the peaks as two genuine modes?
- Why can concatenating imputed values from many completed data sets create a misleading impression of sample size or stability?
Solutions. (1) \(IQR=28-20=8\) units. The fences are \(20-1.5(8)=8\) and \(28+1.5(8)=40\) units. Values beyond them are flagged as potential outliers under the plotting rule, not automatically as errors. (2) No. Different predictor composition can produce different marginal distributions even when within-stratum imputations are reasonable. Examine relevant strata and the imputation model before drawing a conclusion. (3) Check the individual values, sample size, bandwidth, and sensitivity of the estimated shape to smoothing. Six values provide weak evidence for multimodality. (4) The same missing cases recur across imputations, so concatenated values are not independent new cases. Pooling can obscure between-imputation or chain variation and make the display look more stable than the diagnostic information supports.