Comprehensive Lecture Notes on Empirical Economics, Linear Regression, and Causal Inference
Linear Regression and the California School District Case
Econometric analysis typically addresses two fundamental types of questions. An empirical question examines whether an observed empirical association exists between two variables, such as class size and student learning outcomes. A policy question goes further by exploring the causal effect of an intervention, seeking to quantify the ceteris paribus impact on learning outcomes when class size is reduced by a single student.
Evaluating these questions requires measuring educational achievement. Educational outcomes can be proxied through various metrics, including parental satisfaction, future earnings of pupils, long-term child welfare, or standardized comparative examination scores such as those from the Programme for International Student Assessment (PISA).
In the California Test Score dataset from 1999, the sample comprises all elementary ( and ) school districts across the state. The primary variables of interest are , which represents the district average performance of fifth graders on the Stanford-9 standardized achievement test combining reading and mathematics, and (Student-Teacher Ratio), defined as the total number of enrolled students in a district divided by the number of full-time equivalent teachers. Summary statistics reveal that has a sample mean of students per teacher with a standard deviation of , having a quantile of , a median ( quantile) of , and a quantile of . Meanwhile, has a sample mean of with a standard deviation of , displaying a quantile of , a median of , and a quantile of .
The theoretical framework begins with the true, unobserved population regression relationship, expressed as . In generalized bivariate notation, this is formulated as for . Here, the independent variable is alternatively known as the regressor, explanatory variable, exogenous variable, right-hand side variable, or cofactor. The dependent variable is known as the endogenous, explained, or left-hand side variable. The parameter is the intercept, denoting the expected baseline value of when , while represents the slope parameter defining the marginal effect . The term is the unobserved population error term or disturbance, which encompasses all determinants of outside of , including omitted exogenous variables and measurement error in the dependent variable.

Ordinary Least Squares (OLS) Estimation and Properties
Because the population parameters are fundamentally unobservable, sample estimators and are chosen to minimize the sum of squared differences between observed values and the fitted regression line, a quantity termed the Sum of Squared Residuals (): . Taking the first-order partial derivatives with respect to and , setting them to zero, and solving yields the analytical Ordinary Least Squares (OLS) estimators: and . Using these parameter estimates, the fitted or predicted values are given by , while the sample residuals are computed as .
OLS estimation is preferred for multiple theoretical and practical reasons. First, OLS serves as a natural generalization of the sample mean; imposing the slope restriction reduces the OLS intercept estimator directly to the sample mean of the dependent variable (). Second, under standard Gauss-Markov conditions, OLS estimators are unbiased, meaning . Third, OLS estimators achieve efficiency, having the lowest variance among all linear unbiased estimators (attaining Best Linear Unbiased Estimator, or BLUE, status). Finally, OLS is universally adopted as the lingua franca across empirical economic research.
Applying bivariate OLS estimation to the California dataset yields the sample regression line , where the intercept estimate is and the slope estimate is . For example, the Antelope School District exhibits an observed of and an actual of . The predicted score for Antelope is calculated as , which produces an estimated residual of .

Goodness-of-Fit Measures
Assessing regression fit starts with the algebraic decomposition of the sample variation based on the identity . This yields the sum of squares decomposition , or . Here, the Total Sum of Squares () quantifies total sample variation in the dependent variable, the Explained Sum of Squares () measures variation accounted for by the model, and the Sum of Squared Residuals () represents unexplained sample variation.
The Coefficient of Determination () reflects the proportion of sample variance in explained by the regressor , defined as . It is a dimensionless metric strictly bounded such that . An of zero indicates that the regressor explains none of the variation in , whereas an of one signifies that every data point lies on the fitted regression line (). In a simple bivariate linear regression, is mathematically identical to the square of the sample correlation coefficient between and , satisfying .
The Standard Error of the Regression () provides an estimator of the standard deviation of the error term , capturing the typical magnitude of a sample residual: . The is expressed in the identical units of measurement as the dependent variable . In the California test score application, the regression yields ( of variance explained) and (rounded to ). Although accounts for only a modest share of the dispersion in test scores and typical prediction errors remain substantial, this low fit does not imply that class size lacks economic or policy relevance.
Core Least Squares Assumptions and Sampling Distributions
To conduct valid statistical inference, bivariate OLS relies on three classical assumptions. Assumption 1 specifies that the conditional expectation of the error term given the regressor is zero: for all . This ensures that the disturbance contains no systematic information regarding , which implies . In the class size application, the error term encompasses family background, parental learning support, and extra school facilities. If family income acts as a proxy for these omitted factors, requires that average family income is invariant across all levels of , an assumption frequently violated in observational data. Assumption 2 mandates that observations for are independently and identically distributed (i.i.d.), which naturally holds under simple random sampling from a single large population but is routinely violated in time-series data due to autocorrelation. Assumption 3 requires finite fourth moments, and , ensuring that the distributions of and possess finite kurtosis and thin tails, preventing extreme outliers from dominating the estimator.
The OLS estimator is a random variable characterized by sampling variability across draws. Under Assumptions 1 and 2, is unbiased (). For large sample sizes , the asymptotic variance is defined by . Invoking the Central Limit Theorem, as , the estimators converge to normal asymptotic distributions: and . Asymptotic normality requires only Assumptions 1 through 3 and does not depend on the underlying error terms being normally distributed, allowing standardization to standard normal distributions: and .
Hypothesis Testing and Confidence Intervals in Bivariate Models
A classical -statistic is constructed as the ratio . For testing the null hypothesis against the two-sided alternative , the test statistic is . The consistent estimator of the variance is computed as , whose square root yields the standard error . Under asymptotic normality, the decision rule dictates rejecting at the significance level () if , and at the significance level () if . The two-sided -value is given by .
In the California class size application, testing against uses the point estimate , heteroskedasticity-robust standard error , and intercept standard error . The resulting -statistic is . Because and exceeds , the null hypothesis of no relationship is rejected at both the and significance levels ( under robust estimation). A confidence interval is constructed as , which evaluates to . Because this interval excludes zero, the null hypothesis is rejected.
Academic reporting conventions summarize regression equations with standard errors placed directly in parentheses below the estimated coefficients: , alongside and . Across software platforms, default outputs often assume homoskedasticity unless robust options are selected. In R, lm yields an intercept estimate of (, ) and an slope of (, ) under homoskedastic defaults, but robust adjustment via vcovHC shifts to (, ). Python's statsmodels OLS reports unadjusted standard errors of and with an -statistic of , , , and Durbin-Watson statistic of . EViews provides identical unadjusted parameters with mean dependent variable and log-likelihood . Stata (regress testscr str, r) defaults directly to robust variance estimation, yielding () and a confidence interval of . Microsoft Excel computes solely homoskedastic statistics, reporting a multiple correlation of , , and adjusted .

Binary Independent Variables (Dummy Variables)
A binary independent variable or dummy variable takes on strictly two values: . In the regression model , the conditional expectations for the two subsamples are and . Under this formulation, represents the baseline reference group mean where , while represents the difference in population expectations between the two groups, defined as .
In the California school district context, defining an indicator variable for small classes such that if and if produces the estimated regression line . This result indicates that school districts with small student-teacher ratios average an estimated points higher on standardized examinations. Testing against yields a -statistic of , demonstrating that the score difference between small and large class sizes is statistically significant beyond the level ().
Homoskedasticity vs. Heteroskedasticity
The conditional variance of the error term determines whether errors are homoskedastic or heteroskedastic. Errors are homoskedastic if the conditional variance given the regressor is constant for all values of , satisfying . Errors are heteroskedastic if the conditional variance varies as a function of the regressor: . Under homoskedasticity, the Gauss-Markov theorem proves that the OLS estimator achieves BLUE status, and the estimator variance simplifies to , estimated by .
Under heteroskedasticity, the Eicker-Huber-White robust standard error formula must be employed: . Because statistical software packages routinely default to homoskedastic formulas unless manually overridden, applying homoskedastic standard errors in the presence of heteroskedasticity leads to systematically biased standard errors, erroneous -statistics, invalid -values, and incorrect confidence intervals. In contrast, heteroskedasticity-robust standard errors remain asymptotically valid even if the errors are purely homoskedastic, as both formulas converge to identical values when . Consequently, modern empirical practice dictates using heteroskedasticity-robust standard errors as standard protocol.
Causality and the Ideal Randomized Controlled Experiment
The negative empirical association observed between class size and test scores () does not establish a causal mechanism. In observational settings, affluent school districts possess higher tax revenues, enabling them to hire more teachers (reducing ) while concurrently funding superior learning facilities, instructional technology, and tutoring support. Consequently, the error term and the regressor are correlated (), which violates OLS Assumption 1 ().
In econometric theory, a causal effect is formally defined as the quantitative impact that would be measured within an ideal randomized controlled experiment. Such an experiment is ideal because all subjects comply fully with the experimental protocol without attrition, non-response, or measurement error. It is randomized because individuals from the population are randomly sampled and assigned to treatment or control arms, ensuring that treatment status is statistically independent of all baseline characteristics. Finally, it is controlled because an untreated baseline control group is retained to benchmark counterfactual outcomes.
Multiple Linear Regression and Omitted Variable Bias
Omitted variable bias occurs when an excluded variable causes the OLS estimator to be biased and inconsistent. Specifically, an omitted variable introduces bias in the coefficient of if and only if two conditions hold: first, must be a determinant of the dependent variable (i.e., contained within ); second, must be correlated with the included regressor (). Under these conditions, the estimator converges according to the asymptotic bias formula: , where represents the population correlation coefficient between and the error term .
This bias can be demonstrated using the percentage of English language learners (). Because English learners face instructional barriers, higher directly lowers test scores, meaning is a determinant of . Furthermore, districts with high immigrant shares often face budget constraints, leading to higher (). Because higher lowers (), the resulting error-regressor correlation is negative (). Consequently, the simple regression slope is negatively biased away from zero, exaggerating the true magnitude of the class size effect.
An empirical subsample analysis across English learner quartiles highlights this omitted variable bias. Across all districts combined, small classes (, ) average a score of , whereas large classes (, ) average , generating a difference of points (). However, when evaluating districts within homogeneous demographic strata, the differences shrink dramatically: for , the difference is points (); for , the difference is points (); for , the difference is points (); and for , the difference is points (). Controlling for English proficiency reveals that within similar demographic groups, the difference attributable to class size becomes statistically indistinguishable from zero.
To control for confounding factors, the general multiple regression model incorporates regressors: . In this framework, the slope coefficient reflects a ceteris paribus marginal effect: , holding all other regressors constant. Estimating the California class size model with an added control for English learners yields . Incorporating cuts the estimated class size effect by more than half, moving the coefficient from to .
In multiple regression, goodness-of-fit is assessed using the Standard Error of the Regression, , and the Adjusted Coefficient of Determination (), defined as . While unadjusted mechanically increases or stays constant whenever another regressor is added, penalizes the loss of degrees of freedom, is strictly less than , and can take negative values. In California, moving from a single regressor () to two regressors ( and ) increases from to , raises from to , and reduces from to .
Multiple regression requires four core OLS assumptions: first, ; second, are i.i.d. draws for ; third, finite fourth moments hold such that for all and ; and fourth, no perfect multicollinearity exists. Perfect multicollinearity occurs when one regressor is an exact linear combination of other regressors, which prevents matrix inversion during estimation, such as including dummy variables for both small and large classes alongside a common intercept.
Hypothesis Testing with Multiple Restrictions
When evaluating multiple parameter restrictions, conducting separate univariate -tests distorts the overall Type I error rate. For instance, in a model specified as , testing the joint null hypothesis that school resources have zero impact ( against ) by rejecting whenever either or inflates the true significance level well beyond the nominal .
To maintain the correct size of the test, an -test must be employed. For two joint restrictions (), the heteroskedasticity-robust -statistic is defined as , where is the estimated correlation between the two individual -statistics. Under , this statistic asymptotically follows a distribution, where represents the number of restrictions. Large-sample critical values for -tests at the and levels are, respectively: and for ; and for ; and for ; and for ; and and for .
In the California dataset, estimating the model with expenditure per student yields . While individual -statistics report () for and () for , testing the joint restriction yields an -statistic of (). Because , the joint null hypothesis is rejected at the level, confirming that school resource variables are jointly significant despite the statistical insignificance of class size in this specification.
Testing single linear restrictions across coefficients () can be accomplished through reparameterization or direct -testing. Under reparameterization, defining allows the regression to be rewritten as (where ), permitting a standard -test of . Alternatively, direct software testing of str = expn_stu yields (), which fails to reject equality. Furthermore, the joint confidence region for two coefficients constitutes an ellipse defined by all parameter pairs that cannot be rejected at the significance level: . Constructing independent square regions from univariate intervals is methodologically invalid because it ignores correlation between estimators.
Model Specification and Comparative Analysis
Sound model specification strategy entails establishing a baseline specification and contrasting it against plausible alternatives that incorporate additional control variables. An increase in or does not demonstrate causality, validate regressor selection, or prove the absence of omitted variable bias; model selection must always be guided by economic theory.
A comparative analysis across five benchmark specifications for California school districts () demonstrates how coefficient estimates stabilize once relevant socioeconomic variables are introduced:
In Model (1), a simple bivariate regression on produces a slope of (, ) with an intercept of (), , and .
In Model (2), adding the percentage of English learners shifts the coefficient to (, ) and yields an English learner coefficient of (, ), an intercept of (), , and .
In Model (3), including the percentage of students qualifying for subsidized lunch yields an slope of (, ), an English learner coefficient of (, ), a subsidized lunch coefficient of (, ), an intercept of (), , and .
In Model (4), substituting the percentage qualifying for income assistance in place of subsidized lunch results in an slope of (, ), an English learner coefficient of (, ), an income assistance coefficient of (, ), an intercept of (), , and .
In Model (5), incorporating all four regressors results in an coefficient of (, ), an English learner coefficient of (, ), a subsidized lunch coefficient of (, ), an income assistance coefficient of (, not statistically significant), an intercept of (), , and .
Nonlinear Regression Models
Linear models impose the restriction that the marginal effect of on remains constant. When economic phenomena display diminishing or accelerating returns, a linear model suffers from functional form misspecification. In the general nonlinear regression model with , the estimated marginal change is evaluated as .
One common method for capturing nonlinearity is polynomial regression, which expresses the conditional mean as an -th degree polynomial: . When applied to district average income (, in thousands of dollars), the estimated quadratic regression function is . The heteroskedasticity-robust -statistic on is , strongly rejecting the hypothesis of a linear functional form. The marginal effect of income diminishes at higher baseline levels: an income increase from to yields ; from to , the change is ; from to , the change is ; and from to , the change becomes .
Another approach relies on logarithmic transformations, exploiting the mathematical property that for small changes. Three specifications are widely used:
In a linear-log model, given by , a increase in leads to an absolute change in of approximately . For the California data, , implying that a increase in district income increases test scores by roughly points.
In a log-linear model, specified as , a one-unit absolute increase in induces a relative proportional change in of approximately , where represents a semi-elasticity.
In a log-log model, formulated as , a change in leads to a change in , making an elasticity. For California, , indicating that a increase in income produces a increase in test scores. Notably, goodness-of-fit metrics ( and ) cannot be compared between specifications that use different transformations of the dependent variable ( versus ).
Interaction Effects
Interaction terms allow the marginal effect of one regressor to depend on the level of another regressor. Three primary interaction specifications are commonly implemented.
First, interactions between two dummy variables are specified as . In this model, the conditional expectation when both indicators equal zero is , whereas the difference in expectations between and for a given is . In the College Distance dataset, modeling years of completed education () as a function of parental college attainment ( and ) yields . Expected education is years when neither parent completed college, years when only the mother completed college, years when only the father completed college, and years () when both parents completed college.
Second, interactions between a continuous variable and a dummy variable take the form . This specification generates two distinct regression lines: for , the line is , while for , the line is , yielding a marginal effect of . In California, defining if and otherwise yields . The slope is for low English learner districts and () for high English learner districts. A joint test of group differences () yields an -statistic of ().
Third, interactions between two continuous variables are formulated as , producing the marginal effect . Modeling the interaction between class size and English learners yields , which establishes the marginal effect of class size as .
Assessing Validity in Econometric Studies
Evaluating empirical studies requires distinguishing between internal and external validity. Internal validity requires that statistical inferences regarding causal parameters are correct for the population under study. External validity requires that these inferences can be generalized across different populations, geographical contexts, time periods, and institutional environments.
Internal validity faces five primary threats. The first threat is omitted variable bias, which arises when omitted determinants correlate with included regressors; it can be mitigated using control variables, randomized experiments, panel data, or instrumental variables. The second threat is functional form misspecification, which occurs when linear functions are applied to nonlinear relationships, causing biased estimates of marginal effects; this is addressed through polynomial or logarithmic transformations.
The third threat is errors-in-variables, caused by measurement error in the regressors due to recording errors, recollection errors, or intentional misreporting. When the observed variable is , the estimated regression becomes , where . Because the covariance between the measured regressor and composite error is , classical attenuation bias pulls the estimator toward zero, rendering OLS biased and inconsistent.
The fourth threat is sample selection bias, which arises when the sampling mechanism depends on the value of the dependent variable . For example, studying ten-year investment returns exclusively using active funds that survived the full decade creates positive selection bias () because underperforming funds were liquidated, thereby overestimating average returns.
The fifth threat is simultaneous causality or endogeneity, which occurs when bidirectional feedback exists between and . In the system and , a shock directly changes , which in turn alters if , inducing . If educational authorities allocate extra funding to reduce class sizes specifically in districts with low examination scores (), the OLS estimate suffers from positive bias, obscuring the beneficial impacts of smaller classes.
Instrumental Variables Regression
Instrumental variables (IV) regression addresses omitted variable bias, measurement error, and simultaneous causality by decomposing an endogenous regressor into an uncorrelated exogenous component and a correlated endogenous component. A valid instrument must fulfill two conditions: instrument relevance, requiring , and instrument exogeneity, requiring .
Two-Stage Least Squares (TSLS) operationalizes IV regression in two sequential steps. In Stage 1, the endogenous regressor is regressed on the instrument and any included exogenous regressors to isolate the exogenous variation: , generating predicted values . In Stage 2, the dependent variable is regressed on the predicted values and controls : . Analytically, the simple IV estimator is expressed as . Standard OLS errors from the second stage must never be used because they ignore the estimation uncertainty associated with ; specialized TSLS routines must be utilized.
Identification depends on the relationship between the number of instruments () and the number of endogenous regressors (). A model is exactly identified when , allowing unique parameter estimation. It is over-identified when , providing excess instruments that permit empirical tests of instrument exogeneity. It is under-identified when , in which case the parameters cannot be estimated without additional instruments.
Empirical applications illustrate these principles. In butter demand estimation, equilibrium price and quantity are determined simultaneously by supply and demand; rainfall in dairy-producing regions serves as an instrument because it shifts supply exogenously without shifting consumer demand. In cigarette demand across 48 U.S. states in 1995, estimating with instrument (sales tax) yields a price elasticity of (). Adding a second instrument (cigarette-specific tax) produces an over-identified model () with a price elasticity of (), where the additional instrument sharpens estimation precision by shrinking the standard error.
Instrument diagnostics focus on detecting weak instruments and testing exogeneity. Instruments are weak when they have little explanatory power in the first-stage regression (coefficients ). When , the sample covariance in the denominator approaches zero, leading to unstable estimators and non-normal sampling distributions. As a diagnostic rule of thumb, the first-stage -statistic testing must exceed ; values below signify weak instruments. Exogeneity cannot be tested in an exactly identified model, but in an over-identified model (), a Hansen-Sargan -test can test the joint null hypothesis that all instruments are uncorrelated with the disturbance.
Panel Data Models and Fixed Effects
Longitudinal panel data track the same cross-sectional entities across time periods, represented as for and . A balanced panel contains complete observations across all entities and periods ( observations), whereas an unbalanced panel contains missing records for some entities in certain periods.
In the U.S. state traffic fatality and beer tax dataset ( states from 1982 to 1988, , ), cross-sectional bivariate regressions yield positive slope coefficients: (, not statistically significant) and (). This counterintuitive positive relationship is driven by omitted variable bias: unobserved, time-invariant state characteristics, such as highway infrastructure quality, rural road density, and cultural drinking norms, confound the cross-sectional estimates.

When , a before-and-after comparison using first differences eliminates time-invariant omitted variables . Differencing the regression equations between 1988 and 1982 yields: . Estimating this difference model produces . By purging the time-invariant state characteristics, the estimated slope flips from positive to a statistically significant negative coefficient (), indicating that a increase in beer tax per case reduces traffic fatalities by deaths per people.

For panels where , the entity fixed effects model is specified as , where captures entity-specific intercepts representing fixed effects. The model can be written equivalently using dummy variables: . To estimate the model efficiently without inverting large matrices, the entity-demeaned (within) algorithm computes entity-specific time averages and , subtracts them to eliminate , and estimates via OLS. In the traffic fatality application, state fixed effects yield (), which is statistically significant at the level.
Time fixed effects models control for unobserved variables that vary over time but affect all entities equally, such as national macroeconomic conditions or federal automobile safety regulations: , where denotes time-specific intercepts. Combining both dimensions yields the entity and time fixed effects model, , which eliminates bias from both time-invariant entity variables and entity-invariant temporal shocks. Applied to the traffic fatality data, the estimated model is . The resulting coefficient is statistically significant at the level (), though not at the level.
Fixed effects estimation requires strict exogeneity (), i.i.d. draws across entities, finite fourth moments, and no perfect multicollinearity. Furthermore, because errors within the same entity over time are typically autocorrelated, standard errors must be computed using Heteroskedasticity- and Autocorrelation-Consistent (HAC) estimators clustered at the entity level to prevent severe underestimation of sampling uncertainty.