From the free course Econometric Theory and Empirical Analysis with Stata on Lykke
Course Assessments and Problem Sets
Key concepts: Stata Output Interpretation · Hypothesis Testing Practice · Model Specification · Problem Set Solutions
Collection of practice exams, homework solutions, and study guides for the midterm and final assessments.
Course Assessments and Problem Sets
In the study of econometrics, the transition from theoretical understanding to empirical mastery occurs within the crucible of assessments and problem sets. These exercises are designed to simulate the workflow of a professional data analyst or academic researcher: cleaning raw data, specifying a model based on economic theory, executing the estimation via software (Stata), and—most crucially—interpreting the results through the lens of causal inference.
Successful navigation of these assessments requires more than just memorizing formulas; it demands a deep intuition for the Gauss-Markov assumptions, the mechanics of Ordinary Least Squares (OLS), and the ability to detect and correct for violations like heteroskedasticity or endogeneity.
The Anatomy of Stata Output Interpretation
The cornerstone of every problem set is the interpretation of the Stata regress output. A standard regression table contains three primary components: the Analysis of Variance (ANOVA) table, the Model Fit section, and the Coefficient Table.
The Coefficient Table
This is the "heart" of the output. For a model $Y = \beta_0 + \beta_1 X_1 + \dots + \beta_k X_k + u$, Stata provides estimates for each $\beta_j$.
| Column | Name | Description | Mathematical Identity |
|---|---|---|---|
| Coef. | Point Estimate | The estimated effect of $X_j$ on $Y$, holding other factors constant. | $\hat{\beta}_j$ |
| Std. Err. | Standard Error | The estimated standard deviation of the sampling distribution of $\hat{\beta}_j$. | $se(\hat{\beta}_j) = \sqrt{\widehat{Var}(\hat{\beta}_j)}$ |
| t | t-statistic | The ratio of the coefficient to its standard error. | $t = \frac{\hat{\beta}_j - 0}{se(\hat{\beta}_j)}$ |
| P>|t| | p-value | The probability of observing a t-stat this extreme if $H_0: \beta_j = 0$ is true. | $P( |
| [95% Conf.] | Confidence Interval | The range of values within which we are 95% confident the true $\beta_j$ lies. | $\hat{\beta}j \pm t{c} \cdot se(\hat{\beta}_j)$ |
Key Insight: A coefficient is only as good as its standard error. A large coefficient with an even larger standard error results in a low t-statistic and a high p-value, meaning we cannot reject the null hypothesis that the variable has no effect.
Model Fit and R-Squared
The $R^2$ value represents the proportion of the total variation in $Y$ that is explained by the independent variables in the model. However, $R^2$ mechanically increases as more variables are added. To account for this, we use the Adjusted R-Squared, which penalizes the addition of unnecessary regressors.
$$ \bar{R}^2 = 1 - (1 - R^2) \frac{n - 1}{n - k - 1} $$
Hypothesis Testing Practice
Problem sets frequently require students to perform manual hypothesis tests to ensure they understand the underlying logic of statistical significance.
The t-test for Individual Significance
To test whether a specific variable $X_j$ has a statistically significant effect on $Y$, we follow a four-step process:
- State the Hypotheses: $H_0: \beta_j = 0$ vs. $H_1: \beta_j \neq 0$.
- Calculate the t-stat: $t = \hat{\beta}_j / se(\hat{\beta}_j)$.
- Find the Critical Value: Look up $t_{c}$ for $n - k - 1$ degrees of freedom at the chosen significance level (usually 5%).
- Make a Decision: If $|t| > t_{c}$, reject $H_0$.
The F-test for Joint Significance
When testing whether a group of variables are all zero (e.g., testing if a set of industry dummy variables matters), we use the F-test. This involves comparing a Restricted Model (without the variables) to an Unrestricted Model (with the variables).
F = \frac{(SSR_r - SSR_{ur}) / q}{SSR_{ur} / (n - k - 1)}
Where $SSR$ is the Sum of Squared Residuals and $q$ is the number of restrictions (the number of variables you are testing).
Model Specification and Functional Forms
One of the most common pitfalls in econometrics is "Level-Level" bias—assuming every relationship is linear. Real-world economic data often requires logarithmic or quadratic transformations to satisfy the Ceteris Paribus condition.
Logarithmic Transformations
The interpretation of $\beta$ changes radically depending on the log-specification:
| Model | Dependent Variable | Independent Variable | Interpretation of $\beta_1$ |
|---|---|---|---|
| Level-Level | $y$ | $x$ | $\Delta y = \beta_1 \Delta x$ (Unit change) |
| Level-Log | $y$ | $\ln(x)$ | $\Delta y \approx (\beta_1 / 100) % \Delta x$ |
| Log-Level | $\ln(y)$ | $x$ | $% \Delta y \approx (100 \cdot \beta_1) \Delta x$ |
| Log-Log | $\ln(y)$ | $\ln(x)$ | $% \Delta y \approx \beta_1 % \Delta x$ (Elasticity) |
Quadratic Forms
To capture diminishing or increasing marginal returns (e.g., the effect of experience on wages), we use a quadratic term: $y = \beta_0 + \beta_1 x + \beta_2 x^2 + u$. The "turning point" where the effect of $x$ on $y$ changes direction is calculated as: $$ x^* = \left| \frac{\beta_1}{2\beta_2} \right| $$
Implementation: Stata Workflow
The following code block demonstrates a typical problem set workflow: importing data, generating new variables, running a regression with robust standard errors, and performing a joint hypothesis test.
// 1. Environment Setup
clear all
set more off
capture log close
log using "ProblemSet_Analysis.log", replace
// 2. Data Ingestion and Cleaning
use "http://www.stata.com/data/j_base/wage.dta", clear
label variable wage "Hourly wage in USD"
gen lwage = ln(wage)
gen exper2 = exper^2
// 3. Model Estimation (Multiple Linear Regression)
// We use the 'robust' option to handle potential heteroskedasticity
reg lwage educ exper exper2 tenure, robust
// 4. Post-Estimation: Testing Joint Significance
// Test if experience and tenure are jointly significant
test exper exper2 tenure
// 5. Visualizing the Fit
predict y_hat, xb
scatter lwage educ || lfit lwage educ, title("Wage vs Education")
graph export "regression_plot.png", replace
log close
Mathematical Derivation: The OLS Estimator
To truly understand why Stata produces the numbers it does, one must look at the derivation of the OLS estimator in matrix form. This is the "low-level" implementation of the regression algorithm.
Given the model: Y = Xβ + u
The Goal: Minimize the Sum of Squared Residuals (SSR)
SSR = u'u = (Y - Xβ)'(Y - Xβ)
Expansion:
SSR = Y'Y - β'X'Y - Y'Xβ + β'X'Xβ
Since β'X'Y is a scalar, it is equal to its transpose Y'Xβ:
SSR = Y'Y - 2β'X'Y + β'X'Xβ
First Order Condition (FOC):
∂SSR / ∂β = -2X'Y + 2X'Xβ = 0
Solving for β:
X'Xβ = X'Y
β_hat = (X'X)^-1 X'Y
This result requires that (X'X) is non-singular (no perfect collinearity).
Advanced Topics: Causal Inference
As the course progresses, problem sets shift from simple correlation to Causal Inference. This involves addressing violations of the Zero Conditional Mean assumption ($E[u|X] = 0$).
1. Instrumental Variables (IV)
When $X$ is correlated with $u$ (endogeneity), OLS is biased. We use an instrument $Z$ that is:
- Relevant: $Cov(Z, X) \neq 0$
- Exogenous: $Cov(Z, u) = 0$
2. Difference-in-Differences (DiD)
Used for policy evaluation. It compares the change in outcomes over time between a treatment group and a control group. $$ \delta_{DiD} = (Y_{T, post} - Y_{T, pre}) - (Y_{C, post} - Y_{C, pre}) $$
3. Linear Probability Model (LPM)
When the dependent variable is binary (0 or 1), OLS is referred to as an LPM. While simple to interpret, it has two major flaws: predicted probabilities can fall outside $[0, 1]$, and the error term is inherently heteroskedastic.
Common Pitfalls in Problem Sets
- The Dummy Variable Trap: Including a dummy variable for every category plus an intercept. This causes perfect multicollinearity.
- Solution: Always omit one category (the "base" group).
- Misinterpreting Log-Models: Forgetting to multiply by 100 when interpreting a log-level model. A $\beta = 0.05$ means a 5% increase, not a 0.05% increase.
- Confusing Correlation with Causation: Claiming that $X$ "causes" $Y$ without verifying the Gauss-Markov assumptions, particularly SLR.4/MLR.4 (Zero Conditional Mean).
- Ignoring Significance: Discussing the magnitude of a coefficient that is not statistically significant. If $p > 0.05$, the effect is effectively zero in the population.
Real-World Usage: Python Replication
In modern industry roles (Data Science/Quant Finance), you may need to replicate Stata results using Python's statsmodels library to integrate with a larger production pipeline.
import pandas as pd
import numpy as np
import statsmodels.api as sm
import statsmodels.formula.api as smf
# Load dataset
url = "https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/datasets/cars.csv"
df = pd.read_csv(url)
# 1. Model Specification using Formula API (R-style)
# 'dist ~ speed' means regress distance on speed
model = smf.ols(formula='dist ~ speed', data=df)
# 2. Fit the model with Robust Standard Errors (HC3)
results = model.fit(cov_type='HC3')
# 3. Print the summary (mimics Stata output)
print(results.summary())
# 4. Access specific parameters for downstream logic
beta_speed = results.params['speed']
p_val_speed = results.pvalues['speed']
if p_val_speed < 0.05:
print(f"Speed is a significant predictor (Beta={beta_speed:.4f})")
else:
print("No significant relationship found.")
Summary of Gauss-Markov Assumptions
The validity of the OLS results depends entirely on these assumptions.
| Assumption | Name | Violation Consequence |
|---|---|---|
| MLR.1 | Linear in Parameters | Model is misspecified; estimates are meaningless. |
| MLR.2 | Random Sampling | Sample is biased; results don't generalize to population. |
| MLR.3 | No Perfect Collinearity | The matrix $(X'X)$ cannot be inverted; Stata drops variables. |
| MLR.4 | Zero Conditional Mean | Bias. The most critical assumption for causality. |
| MLR.5 | Homoskedasticity | OLS is no longer BLUE; standard errors are wrong. |
| MLR.6 | Normality of Errors | Small sample inference (t-tests) is invalid. |
- Ceteris Paribus: "All else equal." The requirement that other relevant factors are held constant when estimating the effect of $X$ on $Y$.
- Endogeneity: A situation where an independent variable is correlated with the error term, usually due to omitted variable bias.
- BLUE: Best Linear Unbiased Estimator. The property that OLS has the minimum variance among all linear unbiased estimators.
- P-value: The smallest significance level at which the null hypothesis can be rejected.
- Heteroskedasticity: When the variance of the error term is not constant across observations.
- Instrumental Variable: A variable used to provide exogenous variation to an endogenous regressor.
- If you add a variable to a regression and the $R^2$ increases but the Adjusted $R^2$ decreases, what does this tell you about the new variable?
- Why is the "Zero Conditional Mean" assumption (MLR.4) considered the most important for causal inference?
- In a log-log model ($\ln(y) = \beta_0 + \beta_1 \ln(x) + u$), if $\beta_1 = 1.5$, what is the effect of a 10% increase in $x$ on $y$?
- What happens to the t-statistic of a coefficient if the sample size $n$ increases, holding the effect size and variance constant?
- You are running a regression of "Salary" on "Gender" (Male/Female) and "Education". If you include both a
Maledummy and aFemaledummy along with an intercept, what error will Stata return?
Exam Strategy Checklist:
- Coefficient Sign: Does the sign of $\hat{\beta}$ match economic theory? If not, check for Omitted Variable Bias.
- Statistical vs. Economic Significance: A variable can be statistically significant (low p-value) but economically tiny (small coefficient). Always check both.
- Robustness: Always check if your results hold when using
robuststandard errors. - Functional Form: If the scatterplot looks curved, try adding a quadratic term ($x^2$) or using logs.
- Degrees of Freedom: Remember that $df = n - k - 1$. This is crucial for finding the correct critical values for t and F tests.

Source Materials
Study Econometric Theory and Empirical Analysis with Stata on Lykke
This course page is free to open: signed out, you can read its first two sections, and signing in, on any plan, opens the rest. The free Lykke Chrome extension syncs your own Canvas courses, so ChatGPT, Claude and Muse can answer from your classes and deadlines. It only reads Canvas.
Add the free extensionSign in to open every sectionAll sections of Econometric Theory and Empirical Analysis with Stata · Browse more course pages