In Panel Data Regression, What Do Within R², Between R², and Overall R² Mean?
You ran a panel data fixed effects model in Stata:
1. Introduction: A Moment That Confuses Every Stata Beginner
You ran a panel data fixed effects model in Stata:
xtreg y x1 x2, feAt the bottom of the output, three R² values appear:
R-sq: within = 0.1523
between = 0.3401
overall = 0.2187
Your first reaction is probably—what's the difference between these three R² values? Why does the same model, the same data, and the same variables produce three different R² values? Which one should you report?
This article answers these questions. The core logic actually comes from the fundamental structure of panel data—panel data simultaneously contains two types of variation: changes within the same unit over time (within variation) and differences between different units (between variation). The three R² values respectively measure how much of your model's explanatory power operates along these two dimensions and in combination.
Key takeaway: Within R² measures "how much of the variation within a unit over time is explained by the model," Between R² measures "how much of the long-run differences between units is explained by the model," and Overall R² measures "how much the model explains when both types of variation are pooled together." In a fixed effects model, the core coefficients you care about come entirely from within variation—so Within R² is the measure that best matches your identification strategy.
2. Two Types of Variation in Panel Data: "Changes" Within the Same Unit vs. "Differences" Between Units
2.1 An Example—Schools and Student Performance
Suppose you track 500 schools, each tested once per year on average student performance, for 5 years of data. You want to study "the effect of per-student education funding on student performance."
Panel data structure: school i (i = 1, ..., 500), year t (t = 1, ..., 5).
where is the school fixed effect, used to absorb all time-invariant school characteristics—geographic location, school type (public/private), campus size, school history, etc.
2.2 Two Types of Variation—Why Are There Three R² Values?
Any panel data variable can be decomposed into two parts:
- Between variation: Different schools have different long-run average levels. School A has a five-year average score of 85, while School B has a five-year average of 62—this is "between-school differences." These differences come from schools' long-run characteristics (geographic location, student quality, teacher quality, etc.).
- Within variation: For the same school, performance fluctuates across years. School A scored 82 in 2018 and rose to 88 in 2019—an increase of 6 points. This change may come from increased funding that year, a new principal, policy changes, or other time-varying factors.
The same Y, two different sources of variation. Your model's explanatory power over these two types of variation may be completely different—hence the need for two (actually three) different R² values.
3. How Are the Three R² Values Computed?
3.1 Within R²—How Much of the "Changes Over Time" Does the Model Explain?
Computation method: Extract the "within deviations" (demeaned values) of all variables and run OLS.
- Use as the dependent variable
- Use as the independent variable
- The intercept term is eliminated (the intercept becomes 0 after demeaning), and is also eliminated—this is the essence of the fixed effects model
In this "demeaned" regression, computing the usual R² (SSE/SST) gives the Within R².
Meaning: For a given school, why are its scores high in some years and low in others? Of these "fluctuations over time" in scores, what proportion can be explained by contemporaneous fluctuations in per-student funding?
A Within R² of 0.15 means: of the year-to-year fluctuations in a school's own scores, only 15% can be linked to year-to-year fluctuations in funding. The remaining 85% is driven by other time-varying factors (exam difficulty, teacher turnover, policy adjustments, etc.) and random noise.
3.2 Between R²—How Much of the "Long-Run Differences Between Schools" Does the Model Explain?
Computation method: Collapse all variables to the "group mean" level and run a cross-sectional regression on the 500 school means.
- Use (school i's five-year average score) as the dependent variable
- Use (school i's five-year average funding) as the independent variable
- The sample size goes from 2500 (500 × 5) to 500
The R² computed from this "school average" cross-sectional regression is the Between R².
Meaning: Why do some schools have a five-year average score of 85 while others have only 62? Of these long-run average differences between schools, what proportion can be explained by "differences in long-run average funding"?
Using group-mean regression effectively discards all time-varying information, retaining only cross-sectional (school vs. school) information.
3.3 Overall R²—Without Distinguishing the Source of Variation, Everything Pooled Together
Computation method: Using the coefficients estimated from the fixed effects model, compute fitted values for all observations , then compute the squared correlation coefficient between and .
Meaning: Without distinguishing between "between" and "within," treating all 2500 school-year observations equally—how strong is the correlation between the model's "predicted values" and "actual values" across these observations?
Note: The coefficients used for Overall R² are estimated from the fixed effects model (which only exploits within variation), but the R² computation includes between variation. This creates a possible situation—your coefficients are estimated from within variation, but Overall R² may be inflated by the model's "incidentally decent" explanatory power on the between dimension. And the model's "explanatory power" on the between dimension has no direct relationship with the core coefficients you actually care about (which come from within variation).
3.4 Summary Table
| R² Type | Data Form | Type of Variation Used | Question Answered |
|---|---|---|---|
| Within R² | on | Fluctuations within units over time (within variation) | "Why is the same school higher in some years and lower in others?" |
| Between R² | on (group means) | Long-run differences between units (between variation) | "Why do some schools have high five-year averages while others have low ones?" |
| Overall R² | on (using FE coefficients) | Both types of variation mixed | "Without distinguishing sources, how close are the model's predictions to actual values overall?" |
4. A Numerical Example—To Help You Build Intuition
Back to the 500-school dataset.
Scenario setup:
- School type: Schools with high per-student funding tend to be located in large cities with better student quality and teachers—their five-year average scores tend to be higher. This cross-sectional correlation of "high funding → high scores" contains substantial confounding—being in a large city is itself the deeper reason for better scores, not funding per se.
- But within the same school—when its funding increases in a particular year due to a policy adjustment, scores may indeed rise that year. This "within the same school, more funding → better scores" correlation is closer to the true causal effect.
Fixed effects regression results (hypothetical):
| Coefficient | Estimate | Meaning |
|---|---|---|
| β₁ (funding) | 0.032 | A 1,000 yuan increase in per-student funding → the school's score increases by approximately 0.032 points |
Hypothetical values for the three R² values:
| R² Type | Value | Interpretation |
|---|---|---|
| Within R² | 0.15 | Of the year-to-year fluctuations in the same school's scores, 15% is related to year-to-year fluctuations in funding |
| Between R² | 0.34 | Of the long-run average score differences between schools, 34% is related to long-run funding differences—but this is not a causal effect and contains substantial confounding |
| Overall R² | 0.22 | Treating all observations equally, the model's overall explanatory power is 22%, falling between the other two |
Why is Between R² often higher than Within R²? Because cross-sectional differences between schools (geographic location, student quality, teachers, funding, etc.) are strongly correlated with each other—schools with high funding tend to be "better" on multiple dimensions simultaneously. The R² from a cross-sectional regression reflects this comprehensive "school quality bundle," not just the effect of funding itself.
Why is Within R² often lower? Because for the same school, score fluctuations over five years are small (possibly only a 5–10 point range), and the portion that can be "matched" with five-year funding fluctuations is even smaller. Most year-to-year fluctuations are driven by "noise"—measurement error, exam difficulty, cohort-specific student differences, etc.
5. Which R² Should You Use?—It Depends on Your Identification Strategy
5.1 Fixed Effects Model → Focus on Within R²
In a fixed effects (FE) model, your comes entirely from within variation. The unit fixed effects absorb all time-invariant, between-unit heterogeneity. Therefore—your identification strategy relies on within variation, so you should naturally focus on your model's explanatory power on the within dimension. Within R² is the "working environment" of your model.
In empirical papers, when describing "the model's overall fit," researchers typically report Overall R² (or adjusted R²), but if you're discussing "the model's within explanatory power," use Within R². If you see an extremely low Within R² (e.g., 0.005), this is not necessarily a problem—after removing all between variation, the remaining within variation in many fixed effects models is itself small and noisy, so a low Within R² is normal.
5.2 Random Effects Model → Focus on Overall R²
In a random effects (RE) model, both between and within variation are used. In this case, Overall R² is the most natural measure—the model itself exploits all available information.
However, the RE model requires a demanding assumption ( uncorrelated with X), which is why RE is rarely used as the primary specification in empirical economics research—most use FE, or at minimum conduct a Hausman test to choose between them.
5.3 Between Regression → Focus on Between R²
If the research question is inherently cross-sectional—for example, "why do some countries grow fast in the long run while others grow slowly"—then you care about explanatory power on the between dimension. But in this case, you wouldn't use a panel fixed effects model—you would directly run a cross-sectional regression on the averages.
6. The Range of R² in Empirical Research: What Is Normal? What Should Raise Concerns?
6.1 A Rough Rule of Thumb
Note: The following figures are rules of thumb, not ironclad laws. "Normal" R² values vary enormously across fields, data types, and research questions.
| R² Range | Typical Situation in Empirical Economics | Assessment |
|---|---|---|
| 0.01—0.10 | Fixed effects models with micro data, core regressions after controlling for numerous unit fixed effects and time fixed effects | Perfectly normal, especially in labor, education, and health economics |
| 0.10—0.30 | OLS regressions on micro data (with rich covariates), or FE models on macro panels | Normal and common |
| 0.30—0.60 | Macro time-series regressions, or regressions using aggregated data | Common, but check for spurious regression driven by time trends |
| 0.60—0.85 | Long-span macro time series (e.g., GDP on capital and labor), or data with a high degree of aggregation | Be cautious: check for unit roots (conduct stationarity tests) and overfitting |
| 0.85 and above | Rarely appears in micro data | Highly suspicious: may involve tautology (Y and X are nearly identical), spurious time-trend regression, or inclusion of too many endogenous control variables |
6.2 Within R² Is Usually Low—This Is Not a Problem
The Within R² of a fixed effects model is typically substantially lower than the R² of an OLS regression. This is not because "the model is worse," but because:
First, fixed effects have already removed the richest source of variation (between-unit differences). What remains is the "residual variation" of units fluctuating over time—this part has much smaller fluctuations than the original Y and contains a higher proportion of noise.
Second, treatment variation on the within dimension may be very limited. For many independent variables, the main source of variation is on the between dimension—differences in education funding between schools are far larger than the funding changes within the same school over five years. If your key independent variable changes slowly (a slow-moving variable), within variation is extremely small, and Within R² will naturally be low.
So—in a causal identification paper, a Within R² of 0.03 is perfectly normal. Reviewers will not question you for it. This is not poor fit; it's the "cost" that fixed effects automatically pay to help you achieve identification.
6.3 Excessively High R²—When Should You Be Concerned?
Warning sign 1: R² > 0.90 with non-time-series micro data.
In micro survey data (such as household income regressions), R² rarely exceeds 0.5. If it reaches above 0.9, check—have you included some functional form of Y as a control variable? (For example, regressing "consumption" on "income"—of course R² is high, but this is nearly an identity.)
Warning sign 2: R² jumps dramatically after adding a variable.
If your R² jumps from 0.2 to 0.8 after adding a variable, either that variable has a tautological relationship with Y, or it is an "aggregate variable" that absorbs almost all between variation—it may not be the causal variable you want but rather a proxy for a stronger confounder.
Warning sign 3: Between R² is much higher than Within R² and you're using FE.
This is not a problem per se—in many datasets, between variation is simply more "structured" than within variation. But if you find Between R² = 0.8 while Within R² = 0.02, this indicates that differences between schools (geographic location, long-run student quality → long-run funding levels) "predict" almost all score differences. The score fluctuations that genuinely move with funding on the within dimension are very limited. This may mean—your key independent variable has almost no "experimental variation" on the within dimension—its coefficient estimate is essentially noise-driven. In this case, you should check the first-stage F-statistic (if using IV) or whether the coefficient of variation on the within dimension is too low.
7. Summary
Three sentences to remember the three R² values:
- Within R²: How much of the changes within the same unit over time is explained by the model—this is the heart of the FE model.
- Between R²: How much of the long-run differences between units is explained by the model—this is the world of cross-sectional regression.
- Overall R²: Without distinguishing the source of variation, the model's overall explanatory power—a mixture of both signals.
In empirical research: When using a fixed effects model, Within R² is the measure consistent with your identification strategy. A low Within R² is nothing to be ashamed of—it's the information cost you pay to eliminate confounders. But if a paper claims to use FE for causal identification while reporting Within R² = 0.95—you should ask, "Is this model identifying a causal effect or an identity?"
One sentence to close:
"Panel data has three R² values because one Y has two types of variation—changes over time (within) and differences between units (between). By choosing fixed effects, you've chosen to trust only within variation. So the R² you should report and believe is, naturally, the Within R²."
8. Suggestions for Bilibili/WeChat Public Account Presentation
- Bilibili video: Use "split-screen animation" to show two perspectives of the same panel dataset—the left screen displays one school's score fluctuations along the time axis (within), while the right screen compares the five-year means of all schools side by side (between). Then overlay regression lines on both screens to intuitively show why the same regression line has completely different "explanatory power" on the two dimensions.
- WeChat public account: Present the formulas and corresponding meanings of the three R² values in a three-column comparison table. For the numerical example, include a "school × year matrix chart" of the panel data, using color intensity to represent score levels, visually demonstrating within and between variation.
- Recommended titles:
- Main title: 《Why Does Panel Data Regression Have Three R² Values? Which One Should You Use?》
- Alternative title: 《Within R² Is Only 0.03? Don't Panic—It's Nothing to Be Ashamed Of》
- Key quote:
"By choosing fixed effects, you've chosen to trust only within variation. So the R² you should report and believe is the Within R²."