{% include 'common/meta.html' %}
{% include 'common/header.html' %}

Residual Diagnostics Summary

Model Type
{{ model_type|default('Panel Model') }}
Observations
{{ nobs|default('N/A') }}
Residuals Analyzed
{{ n_residuals|default(nobs)|default('N/A') }}
Diagnostics
{{ n_diagnostics|default('7') }} plots
{% if diagnostics_summary %}
{{ diagnostics_summary.message|default('Residual diagnostics available below') }} {% if diagnostics_summary.description %}

{{ diagnostics_summary.description }}

{% endif %}
{% endif %}

About Residual Diagnostics

Residual diagnostics help assess whether the model assumptions are satisfied. These plots reveal patterns in residuals that may indicate model specification issues, heteroskedasticity, non-normality, or influential observations.

Available Diagnostic Plots

  • Q-Q Plot: Tests normality assumption of residuals
  • Residuals vs Fitted: Checks for non-linearity and heteroskedasticity
  • Scale-Location: Detects heteroskedasticity (non-constant variance)
  • Residuals vs Leverage: Identifies influential observations
  • Residual Time Series: Checks for autocorrelation patterns
  • Residual Distribution: Shows distribution shape with KDE overlay
  • Residual ACF: Autocorrelation function plot (if available)
{% if model_info %}

Model Information

{% if model_info.estimator %} {% endif %} {% if model_info.formula %} {% endif %} {% if model_info.nobs %} {% endif %} {% if model_info.n_entities %} {% endif %} {% if model_info.n_periods %} {% endif %} {% if model_info.r_squared %} {% endif %}
Estimator {{ model_info.estimator }}
Formula {{ model_info.formula }}
Observations {{ model_info.nobs }}
Entities {{ model_info.n_entities }}
Time Periods {{ model_info.n_periods }}
R-squared {{ "%.4f"|format(model_info.r_squared) }}
{% endif %}
{% if residual_charts %}

Residual Diagnostic Plots

Interactive diagnostic plots for comprehensive residual analysis. Hover over data points for detailed information, zoom to focus on specific areas.

{% if residual_charts.qq_plot %}

Q-Q Plot (Quantile-Quantile)

Tests normality assumption. Points should fall along the diagonal line if residuals are normally distributed. Deviations indicate departures from normality.

{{ residual_charts.qq_plot|safe }}
{% endif %} {% if residual_charts.residual_vs_fitted %}

Residuals vs Fitted Values

Checks for non-linearity and heteroskedasticity. Should show random scatter around zero with no clear patterns. LOWESS curve helps identify systematic deviations.

{{ residual_charts.residual_vs_fitted|safe }}
{% endif %} {% if residual_charts.scale_location %}

Scale-Location Plot

Detects heteroskedasticity (non-constant variance). Horizontal line with equally spread points indicates homoskedasticity. Upward/downward trends suggest heteroskedasticity.

{{ residual_charts.scale_location|safe }}
{% endif %} {% if residual_charts.residual_vs_leverage %}

Residuals vs Leverage

Identifies influential observations. Points beyond Cook's distance contours (dashed lines) are potentially influential and may affect model fit significantly.

{{ residual_charts.residual_vs_leverage|safe }}
{% endif %} {% if residual_charts.residual_timeseries %}

Residual Time Series

Shows residuals over time to detect autocorrelation patterns. Should appear random with no systematic trends or cycles.

{{ residual_charts.residual_timeseries|safe }}
{% endif %} {% if residual_charts.residual_distribution %}

Residual Distribution

Histogram with kernel density estimate (KDE) overlay. Should approximate normal distribution (bell curve). Deviations indicate non-normality.

{{ residual_charts.residual_distribution|safe }}
{% endif %} {% if residual_charts.residual_acf %}

Autocorrelation Function (ACF)

Shows correlation between residuals at different lags. Bars should fall within confidence bands (blue shaded area) if no significant autocorrelation exists.

{{ residual_charts.residual_acf|safe }}
{% endif %}

Chart Interactions

  • Hover: Move your mouse over data points to see detailed information
  • Zoom: Click and drag to zoom into a region, or use the zoom buttons
  • Pan: After zooming, click and drag to pan around
  • Reset: Click the "Reset axes" button to restore the original view
  • Export: Use the camera icon to download the chart as a PNG image
{% else %}
No diagnostic plots available. Generate residual diagnostics using the visualization system.
{% endif %}

Interpretation Guide

Q-Q Plot

What to look for: Points should fall along the diagonal reference line.

  • Good: Points closely follow the line
  • Heavy tails: Points curve away at extremes (non-normal)
  • Light tails: S-shaped pattern (non-normal)
  • Skewness: Points systematically above/below line

Residuals vs Fitted Values

What to look for: Random scatter around horizontal zero line.

  • Good: No patterns, random scatter
  • Non-linearity: Curved LOWESS line (add polynomial terms)
  • Heteroskedasticity: Funnel shape (variance increases/decreases)
  • Outliers: Points far from zero line

Scale-Location Plot

What to look for: Horizontal line with equal vertical spread.

  • Good: Horizontal LOWESS line, constant spread
  • Heteroskedasticity: Upward/downward trending line
  • Increasing variance: Spread increases with fitted values

Remedies: Use robust standard errors, WLS, or log transformation.

Residuals vs Leverage

What to look for: Points inside Cook's distance contours.

  • Good: All points inside dashed contours
  • High leverage: Points far right (influential on fitted values)
  • Influential: Points outside Cook's distance (high leverage + large residual)

Actions: Investigate influential points - data errors? Outliers? Structural breaks?

Residual Time Series

What to look for: Random fluctuation around zero.

  • Good: No visible patterns or trends
  • Autocorrelation: Clusters of positive/negative residuals
  • Trends: Systematic upward/downward movement
  • Cycles: Repeated patterns over time

Remedies: Add lagged dependent variable, use clustered SE, or AR errors.

Residual Distribution

What to look for: Bell-shaped (normal) distribution.

  • Good: Symmetric, bell-shaped histogram
  • Skewness: Long tail on one side
  • Kurtosis: Too peaked or too flat
  • Bimodal: Two peaks (mixture of populations?)

General Recommendations

  • Multiple issues: Prioritize fixing the most severe problems first
  • Outliers: Investigate before removing - may contain important information
  • Heteroskedasticity: Robust standard errors are often sufficient
  • Non-normality: Less critical for large samples (CLT applies)
  • Autocorrelation: Critical for panel data - use clustered/HAC errors
{% include 'common/footer.html' %}
{{ plotly_js|safe }}