Tutorials › Biostatistics › Checking Regression Assumptions and Diagnostics

Regression Analysis

Checking Regression Assumptions and Diagnostics

A practical guide to diagnosing regression models in clinical research, including linearity, normality, homoscedasticity, independence, multicollinearity, outliers, influential observations, residual plots, transformations, and implementation in R and SAS.

Intermediate 18 min read

What You'll Learn

  • Which regression assumptions actually matter for inference
  • How to diagnose nonlinearity using residual plots
  • How to assess normality and constant variance
  • How to identify outliers and influential observations
  • How to evaluate multicollinearity with VIF
  • How to diagnose and fix common regression problems in R and SAS

Introduction

Regression models are among the most widely used statistical tools in clinical research. They are used to estimate treatment effects, identify prognostic factors, adjust for baseline covariates, investigate dose-response relationships, and predict clinical outcomes.

But fitting a regression model is only the beginning.

A model can produce coefficient estimates, standard errors, confidence intervals, and p-values while still providing a poor representation of the data.

Regression diagnostics are the process of determining whether the fitted model is appropriate for the data and whether individual observations or structural features of the data are disproportionately affecting the results.

Key idea: Regression assumptions should not be treated as a checklist of formal hypothesis tests. The goal of diagnostics is to understand whether the model adequately represents the relationship between the outcome and predictors and whether the resulting inference is reliable for the scientific question being asked.

The Linear Regression Model

Consider the standard multiple linear regression model:

$$ Y_i = \beta_0 + \beta_1X_{i1} + \beta_2X_{i2} +\cdots+ \beta_pX_{ip} + \varepsilon_i $$

where:

  • \(Y_i\) is the outcome for subject \(i\).
  • \(X_{ij}\) is predictor \(j\) for subject \(i\).
  • \(\beta_j\) is the corresponding regression coefficient.
  • \(\varepsilon_i\) is the model error.

The fitted value for subject \(i\) is:

$$ \hat Y_i = \hat\beta_0 + \hat\beta_1X_{i1} +\cdots+ \hat\beta_pX_{ip} $$

The residual is the difference between the observed and fitted outcome:

$$ e_i=Y_i-\hat Y_i $$

Most regression diagnostics are ultimately based on understanding these residuals and the relationship between residuals, fitted values, predictors, and individual observations.

What Are the Main Regression Assumptions?

For ordinary least-squares linear regression, the most important assumptions and modeling considerations include:

Assumption / Issue What It Means
Linearity The conditional mean of the outcome is correctly modeled as a function of the predictors.
Constant variance The conditional variance is approximately constant across the fitted-value range.
Independence Observations or errors are appropriately independent given the model structure.
Normality The errors are approximately normally distributed when normal-theory inference is being used.
No severe multicollinearity Predictors should not contain problematic linear redundancy.
No excessively influential observations Individual observations should not disproportionately determine the fitted model.
Correct specification Important predictors, interactions, transformations, and nonlinear terms should be appropriately represented.
Important distinction: Not all assumptions affect the same part of a regression analysis. For example, heteroscedasticity can make ordinary standard errors unreliable, while nonlinearity can bias the interpretation of a coefficient if the mean structure is misspecified. Independence problems can be particularly serious because they can cause standard errors to be much too small.

Assumption 1: Linearity

The linearity assumption does not mean that every predictor must have a straight-line relationship with the outcome.

Instead, it means that the conditional mean is correctly represented by the model being fitted.

For example:

$$ E(Y\mid X)=\beta_0+\beta_1X $$

assumes a linear relationship between \(X\) and the expected value of \(Y\).

If the true relationship is curved, a simple linear term may be inadequate.

Example of Nonlinearity

Suppose change in systolic blood pressure is modeled as a function of age:

$$ E(Y\mid \text{Age}) = \beta_0+\beta_1\text{Age} $$

If blood pressure increases slowly at younger ages and more rapidly at older ages, the relationship may instead resemble a curve.

A residual-versus-predictor plot can reveal this problem.

Diagnostic pattern: If residuals form a systematic curve rather than a random cloud around zero, the mean structure may be misspecified.

Residuals and Fitted Values

The most fundamental regression diagnostic is the residual-versus-fitted plot.

Plot:

$$ e_i \quad\text{versus}\quad \hat Y_i $$

A well-behaved residual plot should generally show a pattern resembling a random horizontal cloud centered around zero.

Residual Pattern Possible Problem
Random cloud around zero Generally consistent with an adequate mean/variance structure
U-shaped curve Nonlinearity
Inverted U-shaped curve Nonlinearity
Increasing spread Heteroscedasticity
Decreasing spread Heteroscedasticity
Distinct clusters Potential missing grouping variable or dependence structure
Isolated extreme points Potential outliers

What a Good Residual Plot Looks Like

The idealized pattern is:

✓
Residuals are centered approximately around zero.
✓
There is no obvious curve.
✓
The vertical spread is reasonably stable.
✓
There are no isolated observations dominating the plot.

Assumption 2: Homoscedasticity

Homoscedasticity means that the conditional variance of the outcome is approximately constant across the relevant predictor or fitted-value range.

In mathematical form:

$$ \operatorname{Var}(Y\mid X)=\sigma^2 $$

When the variance changes systematically with the mean, the data are heteroscedastic.

The Classic Funnel Shape

A common diagnostic pattern is a funnel:

  • Narrow residual spread at low fitted values
  • Increasing residual spread at high fitted values

This suggests that the variance increases as the expected outcome increases.

Why it matters: Ordinary least-squares coefficient estimates can remain useful under heteroscedasticity, but the conventional standard errors, confidence intervals, and hypothesis tests may no longer have their intended properties.

Residuals Versus Fitted Values for Variance Diagnostics

The residual-versus-fitted plot is useful for assessing both linearity and constant variance.

For example:

Pattern Interpretation
Constant vertical spread Consistent with homoscedasticity
Fan-shaped spread Potential increasing variance
Reverse fan Potential decreasing variance
Curved mean pattern Potential nonlinearity

Scale-Location Plots

A scale-location plot displays approximately:

$$ \sqrt{|r_i|} \quad\text{versus}\quad \hat Y_i $$

where \(r_i\) is a standardized or standardized-type residual.

This plot is particularly useful for detecting changes in residual spread.

A roughly horizontal band with relatively stable spread is desirable.

Assumption 3: Normality

Normality is frequently misunderstood.

The assumption is generally about the conditional errors, not about the raw outcome variable itself.

The classical model assumes:

$$ \varepsilon_i\sim N(0,\sigma^2) $$

This implies normally distributed residuals when the model is correctly specified.

Normality is particularly relevant for small-sample normal-theory inference.

Do not automatically transform the outcome simply because the raw outcome is not normally distributed. The regression model concerns the conditional distribution after accounting for predictors. A skewed outcome can still produce acceptable residuals in an appropriate model.

Q-Q Plots

A normal Q-Q plot compares the ordered residuals with the theoretical quantiles of a normal distribution.

If the residual distribution is approximately normal, the points should lie reasonably close to a straight line.

Q-Q Pattern Possible Interpretation
Points close to line Residual distribution approximately normal
Heavy tails Potentially heavier-tailed errors
Strong curvature Skewness or other distributional departure
One or more extreme points Potential outliers

Q-Q Plots Versus Formal Normality Tests

A formal test such as the Shapiro-Wilk test can be useful, but it should not be the only diagnostic.

With a very large sample, tiny and practically irrelevant departures from normality can produce very small p-values.

With a very small sample, substantial departures can be difficult to detect.

Practical rule: Use graphical diagnostics and subject-matter knowledge first. A normality test should support—not replace—visual assessment and consideration of sample size and the purpose of the model.

Assumption 4: Independence

Independence means that observations do not contain unmodeled dependence that invalidates the assumed error structure.

This assumption is especially important in clinical research because data are often naturally clustered.

Examples include:

  • Repeated measurements from the same patient
  • Patients treated at the same clinical site
  • Patients nested within physicians
  • Patients within geographic regions
  • Longitudinal measurements
  • Matched subjects

If multiple observations come from the same patient, treating them as independent observations is generally inappropriate.

Independence Is a Study-Design Issue

Independence cannot always be diagnosed from a residual plot.

Knowledge of how the data were generated is essential.

Clinical example: Suppose each patient has blood pressure measured at baseline, Week 4, Week 8, and Week 12. There are four observations per patient, but they are not four independent patients. A standard regression model that ignores within-patient correlation may underestimate uncertainty.

Checking Independence in Ordered Data

For time-ordered observations, residuals can be plotted against time or observation order.

Patterns such as runs, trends, or cycles may indicate dependence.

Autocorrelation can also be examined using an autocorrelation function.

$$ \rho_k = \operatorname{Corr}(\varepsilon_t,\varepsilon_{t-k}) $$

where \(k\) represents the lag.

Assumption 5: Multicollinearity

Multicollinearity occurs when predictors contain substantial linear relationships with one another.

For example, suppose a model includes:

  • Weight in kilograms
  • Weight in pounds

These variables contain essentially the same information.

Another example is including highly correlated laboratory measurements in the same model.

Why Multicollinearity Matters

Multicollinearity can cause:

  • Large standard errors
  • Unstable coefficient estimates
  • Unexpected coefficient signs
  • Strong sensitivity to small data changes
  • Difficult interpretation of individual predictor effects

It does not necessarily reduce the predictive performance of the overall model.

Important: A large p-value for an individual coefficient does not necessarily mean that the predictor has no relationship with the outcome. Severe multicollinearity can make it difficult to separate the effects of correlated predictors.

Variance Inflation Factor

The variance inflation factor for predictor \(j\) is:

$$ VIF_j = \frac{1}{1-R_j^2} $$

where \(R_j^2\) is obtained by regressing predictor \(X_j\) on all the other predictors.

A large \(R_j^2\) means that predictor \(j\) is highly predictable from the other predictors, resulting in a large VIF.

VIF Common Interpretation
Approximately 1 Little or no collinearity
1–5 Usually modest
5–10 Potentially concerning
>10 Often considered severe

These thresholds are rules of thumb rather than universal regulatory standards.

Assumption 6: Outliers

An outlier is an observation whose outcome is unusual relative to what the model predicts.

For example, a patient may have an outcome substantially larger or smaller than expected given the patient's covariates.

Outliers can be identified using:

  • Raw residuals
  • Studentized residuals
  • Standardized residuals
  • Q-Q plots
  • Residual-versus-fitted plots

Residual Magnitude

A raw residual is:

$$ e_i=Y_i-\hat Y_i $$

However, raw residuals are not always directly comparable because their variance can differ across observations.

Standardized or studentized residuals are often more useful for diagnostic purposes.

$$ r_i = \frac{e_i}{s\sqrt{1-h_{ii}}} $$

where \(h_{ii}\) is the leverage for observation \(i\).

Leverage

An observation can be unusual not because its outcome is extreme, but because its predictor values are unusual.

Such an observation can have high leverage.

For example, suppose most patients have ages between 40 and 70 years but one patient is 95 years old.

That patient may have substantial leverage because the patient's predictor profile is far from the center of the predictor space.

Key distinction: An outlier is unusual in the outcome direction. A high-leverage observation is unusual in predictor space. An observation can be one, the other, or both.

Hat Values

Leverage is commonly represented by the diagonal elements of the hat matrix:

$$ H=X(X^\mathsf{T}X)^{-1}X^\mathsf{T} $$

The diagonal element \(h_{ii}\) measures how unusual observation \(i\)'s predictor configuration is relative to the other observations.

A common rough screening rule is to investigate observations whose leverage is substantially larger than the average leverage.

Because leverage depends on the number of predictors, rules such as \(2(p+1)/n\) or \(3(p+1)/n\) are sometimes used as screening thresholds.

Screening is not deletion. A high-leverage observation should trigger investigation, not automatic removal.

Influential Observations

An influential observation is one whose presence has a substantial effect on the fitted model.

Influence combines aspects of:

  • Residual magnitude
  • Leverage
  • Model sensitivity

A useful influence diagnostic is Cook's distance.

Cook's Distance

Cook's distance measures how much the fitted regression model changes when an observation is removed.

Conceptually:

$$ D_i \propto \sum_{j=1}^{n} \left( \hat Y_j-\hat Y_{j(i)} \right)^2 $$

where \(\hat Y_{j(i)}\) is the fitted value when observation \(i\) is omitted.

Large values identify observations worthy of investigation.

A commonly used screening rule is:

$$ D_i>\frac{4}{n} $$

but this is a heuristic rather than an automatic deletion criterion.

Why Influential Observations Require Clinical Review

Suppose a clinical trial contains one patient with an exceptionally large treatment response.

The observation might be:

  • A legitimate biological response
  • A measurement error
  • A data-entry error
  • A protocol deviation
  • A genuine but rare patient characteristic

The statistical diagnostic tells you that the observation matters.

It does not tell you whether the observation is wrong.

Best practice: Investigate influential observations using the source data and clinical context. Do not remove observations merely because they make the regression result less statistically significant.

Residual Diagnostics: A Practical Summary

Diagnostic Primary Question
Residual vs fitted Is the mean/variance structure appropriate?
Residual vs predictor Is the relationship with a predictor nonlinear?
Q-Q plot Are residuals approximately normal?
Scale-location Is residual spread approximately constant?
Residual vs time/order Is there evidence of dependence?
VIF Are predictors highly collinear?
Leverage Are predictor values unusual?
Cook's distance Are observations strongly influencing the model?

A Complete Diagnostic Workflow

1
Fit the prespecified regression model.
2
Inspect residuals versus fitted values.
3
Check residuals against important continuous predictors.
4
Assess the residual distribution with a Q-Q plot.
5
Assess whether residual variance changes systematically.
6
Evaluate the study design for dependence or clustering.
7
Check multicollinearity among predictors.
8
Identify observations with unusual residuals or leverage.
9
Assess influential observations using Cook's distance or related diagnostics.
10
Investigate unusual observations against source data and clinical context.
11
Modify the model only when the modification has a scientific or statistical justification.
12
Repeat diagnostics after any substantive model change.

Worked Clinical Example

Suppose a clinical study investigates the association between change in a biomarker and change in a clinical outcome.

The proposed model is:

$$ \Delta Y = \beta_0 + \beta_1\Delta X + \beta_2\text{Age} + \beta_3\text{Treatment} + \varepsilon $$

The analyst fits the model and obtains apparently reasonable coefficient estimates.

The next step is not immediately to report the p-values.

The model should first be diagnosed.

Diagnostic Finding 1: Curved Residual Pattern

Suppose the residual-versus-fitted plot shows a pronounced U-shaped pattern.

This suggests that the linear predictor structure may be inadequate.

A possible solution is to add a quadratic term:

$$ E(Y\mid X) = \beta_0 + \beta_1X + \beta_2X^2 $$

Alternatively, restricted cubic splines or another clinically justified nonlinear modeling approach may be appropriate.

Diagnostic Finding 2: Increasing Residual Variance

Suppose residuals become increasingly spread out as fitted values increase.

Potential approaches include:

  • Transforming the outcome when scientifically appropriate
  • Using heteroscedasticity-consistent standard errors
  • Modeling the variance structure explicitly
  • Considering a different outcome distribution or model family

The correct solution depends on the scientific objective and the nature of the data.

Diagnostic Finding 3: One Highly Influential Patient

Suppose one patient has a very unusual biomarker value and a very large Cook's distance.

The analyst should first inspect:

  • Original laboratory data
  • Units
  • Data-entry history
  • Protocol deviations
  • Timing of measurements
  • Patient treatment exposure
  • Clinical plausibility

If the observation is valid, the primary analysis should generally not simply delete it because it is influential.

A sensitivity analysis can show how much the estimated treatment or biomarker effect changes when the influential observation is included versus excluded under a clearly documented rationale.

Diagnostic Finding 4: High VIF

Suppose the model includes baseline biomarker, change from baseline, and follow-up biomarker.

These variables may be highly correlated.

The resulting VIF values may be large.

Possible solutions include:

  • Removing redundant predictors
  • Using a clinically meaningful parameterization
  • Combining correlated variables
  • Using dimension-reduction methods where appropriate
  • Reconsidering the scientific question being addressed
Do not remove a predictor solely because its VIF is high. The correct response depends on why the predictors are correlated and what effect the model is intended to estimate.

Transformations

Transformations can sometimes improve a regression model by making relationships more linear or stabilizing variance.

Common transformations include:

Transformation Typical Use
\(\log(X)\) Right-skewed predictors or multiplicative relationships
\(\sqrt{X}\) Moderate right skew or count-like measurements
\(X^2\) Curvature
\(1/X\) Strong nonlinear relationships in specific scientific settings
Log outcome Positive, right-skewed outcomes when scientifically appropriate

Log-Transforming the Outcome

Suppose the original model is:

$$ Y=\beta_0+\beta_1X+\varepsilon $$

A log-transformed model is:

$$ \log(Y) = \beta_0+\beta_1X+\varepsilon $$

The interpretation of \(\beta_1\) changes substantially.

For a one-unit increase in \(X\), the expected log outcome changes by \(\beta_1\). On the original scale, this corresponds approximately to a multiplicative effect.

Do not transform variables solely to obtain attractive diagnostic plots. A transformation should have a defensible statistical or scientific motivation, and the interpretation should remain clear.

Polynomial Terms

A quadratic relationship can be modeled as:

$$ E(Y\mid X) = \beta_0+\beta_1X+\beta_2X^2 $$

The marginal relationship is:

$$ \frac{dE(Y\mid X)}{dX} = \beta_1+2\beta_2X $$

Therefore, \(\beta_1\) alone is not the overall effect of \(X\).

This is an important reason to plot predicted relationships rather than interpreting polynomial coefficients in isolation.

Interactions Are Also Part of Model Diagnostics

A model may appear nonlinear because an important interaction has been omitted.

For example, treatment effect might differ according to baseline disease severity.

An interaction model could be:

$$ Y = \beta_0 + \beta_1\text{Treatment} + \beta_2\text{Severity} + \beta_3 (\text{Treatment}\times\text{Severity}) + \varepsilon $$

If \(\beta_3\) is clinically meaningful, the treatment effect is not constant across severity levels.

Model specification matters: Residual diagnostics can identify patterns suggesting that the model is inadequate, but they do not automatically tell you which scientific variable, interaction, or nonlinear term should be added.

Partial Residual Plots

Partial residual plots can help assess whether the functional form of an individual predictor is appropriate after accounting for the other predictors.

They are particularly useful when a multiple regression model contains several continuous covariates.

However, partial residual plots should be interpreted as diagnostic tools, not as automatic evidence that a particular nonlinear form is correct.

Added-Variable Plots

Added-variable plots, also called partial regression plots, examine the relationship between:

  • The residualized outcome
  • The residualized predictor

after accounting for the other predictors.

They can help visualize the contribution of an individual predictor to a multiple regression model.

Residuals Should Be Examined on More Than One Scale

A robust diagnostic workflow may examine:

  • Raw residuals
  • Standardized residuals
  • Studentized residuals
  • Deleted residuals

Different residual definitions answer slightly different diagnostic questions.

Studentized Residuals

Externally studentized residuals account for the estimated variance after excluding the observation being evaluated.

Large absolute values can indicate observations whose outcomes are unusual relative to the fitted model.

A rough screening convention is to investigate observations with absolute studentized residuals around 2 or 3 or larger.

These are screening thresholds, not automatic exclusion rules. Clinical data naturally contain unusual but legitimate patients.

Formal Tests for Heteroscedasticity

Formal procedures such as the Breusch-Pagan test can be used to investigate heteroscedasticity.

The basic idea is to determine whether the squared residuals are related to the predictors or fitted values.

A significant test can provide evidence against constant variance.

However, as with normality tests, formal tests should be interpreted alongside graphical diagnostics and scientific context.

Breusch-Pagan Test Concept

Suppose:

$$ Y_i=X_i^\mathsf{T}\beta+\varepsilon_i $$

The test examines whether the error variance depends systematically on predictors.

Conceptually, the squared residuals are modeled as a function of the predictors.

Evidence of a systematic relationship suggests heteroscedasticity.

What About the Durbin-Watson Test?

The Durbin-Watson statistic is commonly used in time-ordered regression settings to investigate first-order autocorrelation.

It is approximately based on:

$$ DW = \frac{ \sum_{t=2}^{n}(e_t-e_{t-1})^2 }{ \sum_{t=1}^{n}e_t^2 } $$

Values near 2 are generally consistent with little first-order autocorrelation, while values substantially below or above 2 can suggest positive or negative autocorrelation.

However, the appropriate approach for repeated clinical measurements is often a model that explicitly represents within-subject correlation rather than simply applying a Durbin-Watson test.

Regression Diagnostics in R

Suppose a clinical dataset contains:

  • change_y — change in the clinical outcome
  • change_x — change in a biomarker
  • age — baseline age
  • treatment — treatment group

Fit the model:

fit <- lm(
  change_y ~ change_x + age + treatment,
  data = dat
)

summary(fit)

Basic Diagnostic Plots in R

par(mfrow = c(2, 2))

plot(fit)

The standard R diagnostic panel provides four particularly useful views:

  • Residuals versus fitted values
  • Normal Q-Q plot
  • Scale-location plot
  • Residuals versus leverage

These four plots provide a strong first-pass diagnostic assessment.

Residuals Versus Fitted Values in R

plot(
  fitted(fit),
  residuals(fit),
  xlab = "Fitted values",
  ylab = "Residuals"
)

abline(h = 0)

Look for curvature, changing spread, clusters, and isolated observations.

Normal Q-Q Plot in R

qqnorm(
  residuals(fit),
  main = "Normal Q-Q Plot"
)

qqline(residuals(fit))

The primary goal is to determine whether the residual distribution is approximately compatible with the normality assumption needed for the intended inference.

Checking VIF in R

Using the car package:

library(car)

vif(fit)

Review the VIF values together with the correlation structure and scientific meaning of the predictors.

Influence Diagnostics in R

cooks.distance(fit)

hatvalues(fit)

rstudent(fit)

Potentially influential observations can be screened using:

which(
  cooks.distance(fit) > 4 / nrow(dat)
)

This is a screening criterion only.

Influence Plot in R

library(car)

influencePlot(fit)

An influence plot can simultaneously highlight observations with unusual residuals, leverage, and influence.

Checking Linearity With a Continuous Predictor

plot(
  dat$change_x,
  residuals(fit),
  xlab = "Change in biomarker",
  ylab = "Residuals"
)

abline(h = 0)

A systematic curve suggests that the effect of change_x may not be adequately represented by a simple linear term.

Adding a Quadratic Term in R

fit_quad <- lm(
  change_y ~ change_x + I(change_x^2) +
    age + treatment,
  data = dat
)

summary(fit_quad)

The revised model should then undergo the diagnostic process again.

Using Restricted Cubic Splines in R

When the relationship is plausibly nonlinear but should remain smooth, spline methods may be preferable to manually selecting polynomial powers.

library(splines)

fit_spline <- lm(
  change_y ~ ns(change_x, df = 4) +
    age + treatment,
  data = dat
)

summary(fit_spline)

The number and placement of knots should be chosen according to a principled modeling strategy rather than adjusted repeatedly until a desired p-value is obtained.

Heteroscedasticity-Consistent Standard Errors in R

If the mean model is appropriate but variance is nonconstant, robust standard errors may be useful.

library(sandwich)
library(lmtest)

coeftest(
  fit,
  vcov = vcovHC(fit, type = "HC3")
)

This changes the estimated covariance matrix used for inference while leaving the ordinary least-squares coefficient estimates unchanged.

Important: Robust standard errors do not fix a misspecified mean relationship. If the residual plot shows strong curvature, replacing ordinary standard errors with robust standard errors does not solve the underlying nonlinearity.

Checking Normality With Shapiro-Wilk

shapiro.test(
  residuals(fit)
)

The test can be informative, but it should not be used as the sole basis for deciding whether the regression model is acceptable.

Regression Diagnostics in SAS

A standard SAS implementation can use PROC REG for ordinary linear regression.

proc reg data=dat;
    model change_y =
          change_x
          age
          treatment
          / vif
            influence
            r
            clb;
run;
quit;

This requests coefficient estimates, VIF diagnostics, influence diagnostics, and residual-related output.

Residual and Predicted Values in SAS

proc reg data=dat;
    model change_y =
          change_x
          age
          treatment;

    output out=diag
        p=predicted
        r=residual
        student=student_resid
        cookd=cooks_d
        h=leverage;
run;
quit;

The resulting dataset can be used to construct diagnostic plots.

Residual-Versus-Fitted Plot in SAS

proc sgplot data=diag;
    scatter x=predicted y=residual;
    refline 0 / axis=y;
    xaxis label="Fitted Values";
    yaxis label="Residuals";
run;

Normal Q-Q Plot in SAS

proc univariate data=diag normal;
    var residual;
    qqplot residual / normal;
run;

Again, the graphical assessment is generally more informative than relying on a single normality p-value.

Checking Multicollinearity in SAS

proc reg data=dat;
    model change_y =
          change_x
          age
          treatment
          / vif tol collin;
run;
quit;

This provides VIF, tolerance, and additional collinearity diagnostics.

Influence Diagnostics in SAS

proc reg data=dat;
    model change_y =
          change_x
          age
          treatment
          / influence;

    output out=diag
        cookd=cooks_d
        h=leverage
        rstudent=student_resid;
run;
quit;

Observations flagged by these diagnostics should be investigated rather than automatically deleted.

What If the Assumptions Fail?

A diagnostic problem does not automatically mean that the entire analysis must be discarded.

The appropriate response depends on the nature of the problem.

Problem Potential Response
Nonlinearity Transformation, polynomial terms, splines, or alternative model
Heteroscedasticity Robust SEs, transformation, variance modeling, alternative model
Non-normal residuals Assess severity; consider transformation, robust methods, or another model
Dependence Mixed model, GEE, time-series model, clustered SEs, or other appropriate structure
Multicollinearity Reconsider redundant predictors and scientific estimand
Outlier Verify data and clinical context; conduct sensitivity analysis if appropriate
High leverage Investigate predictor values and assess model sensitivity
Influential observation Verify observation and report sensitivity where appropriate

Do Not Automatically Delete Outliers

One of the most common mistakes in regression analysis is:

Find an influential observation → delete it → rerun the model.

This is generally inappropriate.

An influential observation may be scientifically important.

Instead, the analyst should ask:

  • Is the observation correctly recorded?
  • Is the measurement plausible?
  • Was the patient eligible?
  • Was the treatment administered correctly?
  • Was the endpoint assessed correctly?
  • Is the observation part of the intended analysis population?
  • Does the scientific question require retaining the observation?

Sensitivity Analysis for Influential Observations

If an observation is legitimate but highly influential, a sensitivity analysis can compare the primary analysis with a clearly justified alternative.

fit_all <- lm(
  change_y ~ change_x + age + treatment,
  data = dat
)

fit_without <- lm(
  change_y ~ change_x + age + treatment,
  data = dat[-influential_id, ]
)

coef(fit_all)
coef(fit_without)

The purpose is not to choose whichever analysis gives the preferred result.

Instead, the comparison shows whether the substantive conclusion depends strongly on the observation.

Model Assumptions Versus Data Assumptions

It is useful to distinguish assumptions about the statistical model from assumptions about the data-generating process.

For example, normality can often be approximately assessed from residuals.

Independence, however, may require knowledge of how subjects were recruited, randomized, measured, and followed.

Clinical research principle: A beautiful residual plot cannot prove that repeated measurements are independent. Study design and data structure must always be considered.

Regression Diagnostics Are Not Model Selection

Diagnostics and model selection are related but distinct.

Diagnostics ask: Does the fitted model appear compatible with the data?

Model selection asks: Which predictors or functional form should be included?

Using diagnostics to guide scientifically justified model refinement is appropriate.

Repeatedly trying many models solely to find one with favorable p-values is not.

The Danger of Stepwise Modeling

Automated stepwise procedures can produce unstable models, biased coefficient estimates, and overly optimistic p-values.

They also do not replace diagnostics.

A variable being statistically nonsignificant does not necessarily mean it should be removed, particularly when it is a prespecified confounder or important adjustment variable.

Clinical Trial Example: Treatment Effect Adjustment

Suppose the primary model is:

$$ Y = \beta_0 + \beta_1\text{Treatment} + \beta_2\text{Baseline} + \varepsilon $$

The coefficient \(\beta_1\) represents the adjusted treatment effect under the specified model.

Before interpreting \(\beta_1\), the analyst should assess whether:

  • The relationship between baseline and outcome is adequately modeled.
  • Residual variance is reasonably stable.
  • There are important influential patients.
  • There is meaningful dependence not represented in the model.
  • The outcome scale is appropriate for linear regression.

Baseline Covariate Nonlinearity

A common clinical-trial problem occurs when a continuous baseline covariate is forced into the model as a linear term without checking whether that relationship is reasonable.

For example:

$$ Y = \beta_0 + \beta_1\text{Treatment} + \beta_2\text{BaselineAge} + \varepsilon $$

may be too restrictive if the relationship between age and outcome is curved.

A spline-based adjustment may be more appropriate:

$$ Y = \beta_0 + \beta_1\text{Treatment} + f(\text{BaselineAge}) + \varepsilon $$

where \(f(\cdot)\) represents a flexible smooth function.

What Diagnostics Cannot Tell You

Regression diagnostics are powerful, but they have limitations.

They cannot automatically determine:

  • Whether a causal interpretation is valid
  • Whether an omitted confounder exists
  • Whether a biomarker is clinically meaningful
  • Whether the sample is representative
  • Whether the chosen endpoint is scientifically appropriate
  • Whether missing data are missing at random

Those questions require study-design knowledge, subject-matter expertise, and additional statistical methods.

Common Mistakes

  1. Checking only whether p-values are significant. A significant regression coefficient does not establish that the model is appropriate.
  2. Checking normality of the raw outcome instead of residuals. Regression assumptions concern the conditional error structure.
  3. Using only formal assumption tests. Plots often reveal important patterns that a formal test does not adequately describe.
  4. Deleting outliers automatically. An unusual observation may be valid and clinically important.
  5. Using VIF as an automatic variable-deletion rule. Collinearity must be interpreted in the context of the scientific model.
  6. Ignoring the study design. Repeated or clustered observations require appropriate modeling.
  7. Using robust standard errors to fix every problem. Robust SEs do not correct misspecified mean relationships.
  8. Transforming variables solely to improve plots. Transformations change interpretation and should have a defensible rationale.
  9. Ignoring influential observations. Even if an observation is valid, its influence may be important for interpreting the robustness of the results.
  10. Running diagnostics only after seeing an unfavorable result. Diagnostics should be part of the planned analysis workflow rather than a post-hoc search for a preferred model.

A Practical Diagnostic Decision Tree

1
Residuals show curvature? → Investigate nonlinear terms, transformations, interactions, or splines.
2
Residual spread changes? → Investigate heteroscedasticity, transformations, robust SEs, or variance modeling.
3
Q-Q plot shows severe departures? → Assess whether normal-theory inference is sensitive and whether another model or robust approach is appropriate.
4
Observations have large residuals? → Verify the underlying records and assess clinical plausibility.
5
Observations have high leverage or Cook's distance? → Investigate their influence and perform sensitivity analysis when justified.
6
VIF is large? → Determine whether predictors are redundant or whether the scientific estimand needs reconsideration.
7
Repeated or clustered observations? → Consider mixed models, GEE, clustered inference, or another appropriate dependence structure.

Reporting Regression Diagnostics

A statistical report does not need to reproduce every diagnostic plot ever generated.

Instead, it should describe the important findings and how they affected the analysis.

For example:

Example reporting language: "Model diagnostics included assessment of residuals versus fitted values, normal Q-Q plots, leverage, Cook's distance, and multicollinearity. No substantial departures from the assumed mean or variance structure were identified. Potentially influential observations were reviewed against the source data and retained because they were considered valid observations."

When Diagnostics Lead to a Different Model

Sometimes the correct conclusion is that ordinary linear regression is not the appropriate model.

Examples include:

Outcome / Structure Potential Model
Binary outcome Logistic regression
Count outcome Poisson or negative binomial regression
Excess zeros Zero-inflated or hurdle models
Repeated continuous measurements Linear mixed model or GEE
Time-to-event outcome Cox or parametric survival model
Ordinal outcome Ordinal regression
Bounded continuous outcome Potentially transformed or specialized model

The purpose of diagnostics is therefore broader than checking a list of assumptions.

They help determine whether the selected model is appropriate for the type of data and scientific question.

Diagnostics for Logistic Regression Are Different

The concepts in this tutorial primarily describe ordinary linear regression.

Logistic regression has a different conditional distribution and does not assume normally distributed residuals in the same way.

Nevertheless, diagnostics remain essential.

Relevant logistic-regression diagnostics include:

  • Linearity of the logit for continuous predictors
  • Influential observations
  • Leverage
  • Deviance residuals
  • Pearson residuals
  • Calibration
  • Discrimination
  • Separation
Do not transfer linear-regression assumptions mechanically to other regression models. Each model family has its own distributional assumptions, link function, and diagnostic framework.

Diagnostics for Count Regression

For Poisson regression, a key concern is whether the conditional variance is compatible with the Poisson assumption.

The Poisson model assumes:

$$ E(Y\mid X) = \operatorname{Var}(Y\mid X) $$

If the variance is substantially larger than the mean, overdispersion may be present.

This may motivate a negative binomial model or another approach.

The Bigger Principle

Regression diagnostics should be thought of as a process of model criticism.

You start with a scientifically motivated model.

Then ask:

  • Does the model capture the mean relationship?
  • Does the variance behave as expected?
  • Are observations appropriately independent?
  • Are the residuals reasonably compatible with the assumed distribution?
  • Are predictors redundant?
  • Are individual observations disproportionately influential?
  • Does the model make clinical sense?

The answer to these questions determines whether the model should be retained, modified, or replaced.

Final Diagnostic Checklist

Question Diagnostic
Is the mean relationship adequately represented? Residual vs fitted and residual vs predictor plots
Is variance approximately constant? Residual vs fitted and scale-location plots
Are residuals approximately normal? Q-Q plot and, where useful, formal tests
Are observations appropriately independent? Study design, ordering, clustering, autocorrelation diagnostics
Are predictors strongly redundant? Correlation structure and VIF
Are outcomes unusual? Standardized/studentized residuals
Are predictor values unusual? Leverage
Do observations strongly affect the model? Cook's distance and influence diagnostics
Does the model remain scientifically interpretable? Clinical and subject-matter review

Recommended R Workflow

# Fit model
fit <- lm(
  change_y ~ change_x + age + treatment,
  data = dat
)

# Basic model summary
summary(fit)

# Standard diagnostic panel
par(mfrow = c(2, 2))
plot(fit)

# VIF
library(car)
vif(fit)

# Studentized residuals
rstudent(fit)

# Leverage
hatvalues(fit)

# Cook's distance
cooks.distance(fit)

# Influence plot
influencePlot(fit)

Recommended SAS Workflow

proc reg data=dat;
    model change_y =
          change_x
          age
          treatment
          / vif
            influence
            r;

    output out=diag
        p=predicted
        r=residual
        student=student_resid
        cookd=cooks_d
        h=leverage;
run;
quit;

proc sgplot data=diag;
    scatter x=predicted y=residual;
    refline 0 / axis=y;
run;

proc univariate data=diag normal;
    var residual;
    qqplot residual / normal;
run;

What Should Go Into the Statistical Analysis Plan?

When regression is a prespecified primary or key secondary analysis, the SAP should describe the modeling strategy clearly enough that the analysis does not become an informal search for a favorable model.

Relevant documentation may include:

  • Primary outcome definition
  • Primary regression model
  • Prespecified covariates
  • Functional form of continuous covariates
  • Important prespecified interactions
  • Handling of categorical variables
  • Approach to missing data
  • Approach to influential observations
  • Diagnostic procedures
  • Criteria for model modification, if applicable
  • Sensitivity analyses
  • Methods for nonconstant variance or dependence
Best practice: Diagnostics should be planned before examining the final treatment-effect results whenever possible. This helps distinguish legitimate model checking from post-hoc model shopping.

How to Think About a Diagnostic Plot

A diagnostic plot is not asking:

"Does this look perfectly random?"

Instead ask:

  • Is there a systematic structure?
  • Is that structure large enough to matter?
  • Does it affect the scientific conclusion?
  • Is the pattern caused by a small number of observations?
  • Is there a clinically plausible explanation?
  • Would another model describe the data more appropriately?

No real dataset will satisfy every theoretical assumption perfectly.

The goal is to determine whether departures are sufficiently important to change the analysis or interpretation.

The Most Important Concept

Regression diagnostics are not about making a dataset look perfect.

They are about determining whether the fitted model is a reasonable representation of the data for the question being asked.

A good regression workflow therefore looks like:

1
Specify a scientifically justified model.
2
Fit the model.
3
Diagnose residual structure, variance, normality, dependence, collinearity, and influence.
4
Investigate unusual observations using source data and clinical knowledge.
5
Modify the model only when there is a defensible statistical or scientific reason.
6
Re-diagnose the revised model.
7
Report the important diagnostic findings and sensitivity analyses.
Bottom line: Regression diagnostics are an essential part of clinical data analysis. The most useful tools include residual-versus-fitted plots for mean structure and variance, Q-Q plots for residual distribution, residual-versus-predictor plots for functional form, VIF for multicollinearity, leverage for unusual predictor profiles, and Cook's distance for influence. No single diagnostic proves that a model is correct. The analyst should combine statistical diagnostics with study-design knowledge, source-data review, and clinical reasoning. When assumptions are materially violated, the solution may involve transformation, nonlinear terms, robust inference, explicit variance modeling, dependence models, or an entirely different regression model.

References

Fox, J. & Weisberg, S. An R Companion to Applied Regression. Sage Publications.

Kutner, M.H., Nachtsheim, C.J., Neter, J. & Li, W. Applied Linear Statistical Models. McGraw-Hill.

Montgomery, D.C., Peck, E.A. & Vining, G.G. Introduction to Linear Regression Analysis. Wiley.

Harrell, F.E. Regression Modeling Strategies. Springer.

Weisberg, S. Applied Linear Regression. Wiley.

Chatterjee, S. & Hadi, A.S. Regression Analysis by Example. Wiley.