Tutorials › Exam PA - Predictive Analytics › Complete-Case Analysis and Its Selection Risks

Exam PA · Missingness, Outliers, and Factor Levels · Tutorial 171 of 966

Complete-Case Analysis and Its Selection Risks

Calculate who remains after complete-case filtering, and judge whether the retained records still represent the population or relationship of interest.

Intermediate 12 min read

What You'll Learn

  • Define a complete case for a specified analysis and calculate the retained sample size.
  • Use inclusion-exclusion to count records missing one or more required variables.
  • Compare subgroup composition before and after complete-case filtering.
  • Explain when complete-case estimates preserve a population mean and when selection can distort it.
  • Use R to retain the records complete for a stated analysis.
  • Identify why different complete-case samples can complicate model comparisons.

What Complete-Case Analysis Does

A model may require an outcome and several predictors, while some records lack one or more of those values. A common response is to fit the model using only records that have observed values for every variable required by that analysis. This is called complete-case analysis. It is straightforward to implement, but it changes the data being analyzed: both the sample size and the composition of the retained records can differ from those of the original data set.

The key question is therefore not only “How many records remain?” It is also “Do the remaining records support the same estimate or conclusion as the population we want to describe?” A smaller sample increases uncertainty, while selective exclusion can also change the target represented by the analysis. These are distinct issues: retaining fewer records does not automatically create bias, and having many complete cases does not guarantee that selection is harmless.

Definition: For a specified analysis, a complete case is a record with observed values for every variable required by that analysis. Let \(R=1\) indicate that a record is complete and \(R=0\) otherwise. The complete-case sample size is the number of records for which \(R=1\). Completeness is analysis-specific: a record can be complete for a model using \(Y\) and \(X_1\), but incomplete for another model that also uses \(X_2\).

For example, if an analysis needs only a claim outcome \(Y\) and policy duration \(X_1\), missing income \(X_2\) need not exclude a record. Conversely, a record with observed predictors but a missing outcome cannot contribute to fitting a supervised model for that outcome. Defining the variables required by the analysis before counting complete cases helps avoid excluding records unnecessarily.

Counting the Records That Remain

When the data set is available in R, complete.cases() identifies rows with no missing values among the variables supplied to it. The variable list should match the analysis, not indiscriminately include every column in the data set.

Worked Example: Counting Complete Records for a Model

A hypothetical study has 1,000 records. The model requires an observed outcome \(Y\), predictor \(X_1\), and predictor \(X_2\). Among the records, 40 are missing \(Y\), 120 are missing \(X_1\), and 90 are missing \(X_2\). Ten are missing both \(Y\) and \(X_1\), five both \(Y\) and \(X_2\), 20 both \(X_1\) and \(X_2\), and three are missing all three. Find the number and proportion of complete cases.

Method. Count the records missing at least one required value, using inclusion-exclusion to avoid counting overlaps more than once.

The number missing at least one variable is \(40+120+90-10-5-20+3=218\). The pairwise overlaps are subtracted because they were counted twice in the initial sum. The three-way overlap was then subtracted three times, although it should be counted once in the union, so it is added back once.

Therefore, the complete-case count is \(1{,}000-218=782\). The complete-case proportion is \(782/1{,}000=0.7820\), or 78.20%.

In R, the same analysis-specific filter can be written as:

$$ \texttt{cc <- dat[complete.cases(dat[c("Y", "X1", "X2")]), ]} $$

The check is that 218 records are excluded and 782 retained. A common mistake is to add 40, 120, and 90 and conclude that 750 records are complete. That treats all missingness sets as disjoint, even though the problem gives overlaps. The correction is to count their union, as above.

Composition Can Change Even When the Count Is Clear

Complete-case filtering can change the proportions of groups in the analysis. If outcome rates differ across those groups, a change in group composition can change an overall rate even when each group’s own rate is unaffected by filtering. The following calculation separates the effect of composition from changes within groups.

Worked Example: A Changed Overall Outcome Rate

A hypothetical target population has 400 members of Group A and 600 of Group B. The outcome rates are 40% in A and 10% in B. Complete cases include 120 members of A and 480 of B. Assume each group’s outcome rate is unchanged by filtering. Calculate the outcome rate in the full population and among complete cases.

Method. Calculate the number of outcomes in each group, then divide the total number of outcomes by the relevant total population in each analysis.

In the full population, Group A contributes \(400(0.40)=160\) outcomes, and Group B contributes \(600(0.10)=60\). Thus the full-population rate is \( (160+60)/(400+600)=220/1{,}000=0.2200\), or 22.00%.

Among complete cases, the assumed unchanged rates give \(120(0.40)=48\) outcomes in A and \(480(0.10)=48\) in B. The complete-case rate is \( (48+48)/(120+480)=96/600=0.1600\), or 16.00%.

The share of Group A falls from \(400/1{,}000=0.4000\) in the full population to \(120/600=0.2000\) among complete cases. Since A has the higher outcome rate, its reduced representation lowers the overall rate by 0.0600, or 6.00 percentage points. The group-specific rates were held fixed; the difference arises from composition.

Check. The full rate is also \(0.4000(0.40)+0.6000(0.10)=0.2200\). The complete-case rate is \(0.2000(0.40)+0.8000(0.10)=0.1600\). These weighted averages agree with the outcome-count calculations. The common mistake is to report 22 rather than 0.22 as a rate, or to assume that unchanged group-specific rates imply an unchanged overall rate.

This example makes an important condition explicit: the group-specific outcome rates were assumed to remain the same after filtering. If selection also changes which people are retained within each group in a way related to their outcomes, the group-specific rates may change too. In that case, both within-group selection and shifts in group composition can affect the result.

Why Selection Can Distort an Estimate

The complete-case mean estimates the mean among records with \(R=1\). It estimates the population mean without selection bias when being complete is independent of the outcome being averaged. More generally, the relationship between completeness and the quantity of interest determines whether the retained sample represents that quantity.

Result: If \(R\) is independent of outcome \(Y\), then \(E[Y\mid R=1]=E[Y]\), provided the expectations exist and \(P(R=1)>0\). Thus, under this independence condition, complete-case filtering does not change the outcome’s population mean in expectation. It still reduces the available sample size. If completeness depends on \(Y\), this equality need not hold.

The justification follows directly from conditional probability. For a discrete outcome value \(y\), independence means \(P(R=1\mid Y=y)=P(R=1)\). Consequently,

$$ P(Y=y\mid R=1) =\frac{P(R=1\mid Y=y)P(Y=y)}{P(R=1)} =\frac{P(R=1)P(Y=y)}{P(R=1)} =P(Y=y). $$

The complete cases therefore have the same outcome distribution as the population, and hence the same mean when it exists. If completeness instead depends on the outcome, the first equality no longer reduces to \(P(Y=y)\): values with different probabilities of being observed receive different representation among the complete cases. For example, if high-cost claims are more likely than low-cost claims to have missing outcome records, the average cost among complete cases can be lower than the population average.

The independence condition is a clear sufficient condition for an unbiased complete-case mean, not a guarantee for every analysis whenever missingness is called “random.” The missingness mechanism must be considered in relation to the specific outcome, predictors, and estimand. For a regression, selection can alter predictor distributions and the observed outcome-predictor relationship; an unchanged overall outcome mean alone does not establish that a fitted model is unaffected.

A Relationship Can Be Reversed by Selective Exclusion

Worked Example: Complete Cases Reverse a Group Comparison

In a hypothetical population, there are 100 records in each of two groups, \(X=0\) and \(X=1\). The outcome occurs in 20% of group \(X=0\) and 60% of group \(X=1\). Among group \(X=0\), all 20 outcome records and 25% of the 80 non-outcome records are complete. Among group \(X=1\), 20% of the 60 outcome records and all 40 non-outcome records are complete. Compare the full-population and complete-case outcome rates by group.

Method. Calculate the complete and incomplete counts separately for outcome and group, then divide complete outcome counts by complete group totals.

In the full population, group \(X=0\) has 20 outcomes out of 100, a rate of \(20/100=0.2000\). Group \(X=1\) has 60 outcomes out of 100, a rate of \(60/100=0.6000\).

For \(X=0\), all 20 outcome records are complete. Of 80 non-outcome records, \(0.25(80)=20\) are complete. The complete-case total is \(20+20=40\), so its outcome rate is \(20/40=0.5000\).

For \(X=1\), \(0.20(60)=12\) outcome records are complete, and all 40 non-outcome records are complete. The complete-case total is \(12+40=52\), so its outcome rate is \(12/52=0.2308\) to four decimal places.

The full-population comparison is \(0.6000\) versus \(0.2000\), with the higher rate in \(X=1\). Among complete cases, it is \(0.2308\) versus \(0.5000\), so the direction reverses. The selection fractions depend jointly on group and outcome, which changes the group-specific rates among retained records. The common mistake is to compare only the number of complete cases in each group and assume that group totals alone explain the selection effect; here, completeness also differs by outcome within each group.

This example is deliberately stark to make the mechanism visible. In practice, the distortion may be smaller and harder to detect. A comparison of observed missingness rates across groups is useful for auditing selection, but it cannot by itself prove that complete cases represent the unobserved records: the outcomes of excluded records are, by definition, not fully available for that comparison.

Conditions, Interpretation, and Practical Checks

The earlier material on MCAR, MAR, and MNAR provides language for describing assumptions about missingness. Complete-case analysis is easiest to justify when completeness is independent of the values relevant to the estimand, as under MCAR. But that label should not replace a specific statement of what is assumed. For instance, an analysis of a mean outcome needs an argument about how completeness relates to that outcome; a regression needs an argument about whether selection changes the conditional outcome relationship being estimated.

Before fitting a model to complete cases, document the analysis-specific variable list and compare retained with excluded records using values that are observed for both groups, such as fully observed demographic or operational characteristics. These comparisons can reveal substantial composition changes. They are diagnostics, not a proof that the analysis is unbiased, because differences involving unobserved values cannot be checked directly.

In R, calculate and report both the count and proportion retained. For example:

$$ \texttt{keep <- complete.cases(dat[c("Y", "X1", "X2")])}\\ \texttt{sum(keep)}\qquad\texttt{mean(keep)} $$

Here, sum(keep) is the complete-case count, and mean(keep) is the complete-case proportion because keep is a logical vector. If models use different predictors, they may use different complete-case samples. A difference in their fitted results could then reflect a change in the analysis sample as well as a change in model specification. Record the sample used for each model when comparing results.

Key takeaway: Complete-case filtering is a rule for selecting records, not a neutral data-cleaning step. State which variables define completeness, quantify the loss, inspect changes in composition, and explain why the resulting selection is appropriate for the estimand. If that justification is uncertain, describe the limitation rather than treating the retained sample as automatically representative.

Check Your Understanding

For each scenario, calculate the requested quantity and consider what the complete cases represent.

  1. A hypothetical data set has 500 records. Of these, 30 lack \(Y\), 50 lack \(X_1\), and 20 lack \(X_2\). The overlaps are 5 for \(Y\) and \(X_1\), 4 for \(Y\) and \(X_2\), 6 for \(X_1\) and \(X_2\), and 2 for all three. How many records are complete for an analysis requiring all three variables, and what proportion is that? (Answer: 413 records; proportion \(=0.8260\), or 82.60%.)
  2. A population has 300 members of Group C with a 30% outcome rate and 700 members of Group D with a 5% outcome rate. Complete cases include 150 members of C and 350 of D, with the same group-specific rates assumed after filtering. Find the full and complete-case overall rates. (Answer: Full rate \(=(90+35)/1{,}000=0.1250\); complete-case rate \(=(45+17.5)/500=0.1250\).)
  3. In a population, a group has 40 outcome records and 160 non-outcome records. Among complete cases, 30 outcome records and 40 non-outcome records remain. Calculate the full and complete-case outcome rates. Does this example show outcome-related selection? (Answer: Full rate \(=40/200=0.2000\); complete-case rate \(=30/70=0.4286\); yes, the retained outcome and non-outcome records are represented at different rates.)
  4. In a hypothetical two-group population, each group has 100 records. Group \(X=0\) has 30 outcomes; group \(X=1\) has 50 outcomes. Complete cases retain 24 outcomes and 35 non-outcomes in \(X=0\), and 10 outcomes and 45 non-outcomes in \(X=1\). Calculate each complete-case rate and compare their ordering with the full-population rates. (Answer: Complete-case rates are \(24/59=0.4068\) for \(X=0\) and \(10/55=0.1818\) for \(X=1\); the full rates are 0.3000 and 0.5000, so the ordering reverses.)
Clinical Biostats