- A first econometrics lab is where regression stops being algebra and becomes something students can do, check and explain.
- Python, R and Stata all run the same OLS regression; pick the one your department can support, and use Google Colab if installation is the barrier.
- Keep the first lab to one small dataset, one regression and one interpretation, inside a 60-minute plan with fixed timings.
- Most first-lab failures are file paths, silent missing values, categories treated as numbers and default standard errors. Teach the fixes in advance.
- Assess with a short write-up plus a script that runs from top to bottom, then progress to robust standard errors, dummies, IV and difference-in-differences.
You have a timetabled computer room, a class of thirty, and a scheme of work that says “Week 2: first regression lab”. Some of your students have written code before. Most have not. A few are quietly convinced they are “not computer people”. If the first session goes badly, the lab slot becomes an hour students dread all term.
This guide is for that first session, whether you teach a university first course or stretch strong A Level students with real data. It covers why labs matter, how to choose between Python, R and Stata, a timed 60-minute plan, the exact first regression to run in all three languages (with real output you can check), the errors you will see on the day, how to assess lab work fairly, and where to go next.
Why the econometrics lab matters in a first course
Econometrics is taught in two registers. In the lecture room it is algebra: the population regression function, the OLS estimator, the assumptions behind unbiasedness. In the lab it is a decision about which variables go into a model, a table of numbers on a screen and a sentence that has to say what those numbers mean. Students need both, but most only come to believe the theory once they have watched a coefficient change when they add a control variable themselves.
There is a wider argument too. Angrist and Pischke argue that applied econometrics has moved towards estimating specific causal effects and evaluating policy, while much undergraduate teaching still centres on abstract model-building and the classical assumptions[4]. A lab is the natural place to close that gap, because it is where students meet real data, real research designs and the practical question of whether a regression actually answers the question being asked. Their graduate-level companion, Mostly Harmless Econometrics, is built around exactly that empirical habit of mind[3].
Statistics educators make the same case. Two of the six recommendations in the American Statistical Association’s GAISE College Report are “Integrate real data with a context and purpose” and “Use technology to explore concepts and analyze data”[5]. An econometrics lab does both at once.
Choosing Python, R or Stata (and when to use Google Colab)
All three tools estimate the same OLS regression and give the same coefficients, standard errors and R². The choice is about access, support and where your students are heading, not about which language is “best”. The two standard textbooks reflect this: Wooldridge’s Introductory Econometrics has data sets used widely with all three packages[1], and Stock and Watson’s Introduction to Econometrics is taught with each of them in different departments[2].
| Tool | Strengths for teaching | Watch out for | Good fit when |
|---|---|---|---|
| Python (pandas + statsmodels) | Free; widely used in industry and data science; runs in a browser through Google Colab with no installation | More setup words (imports, data frames) before the first regression; several libraries to learn | Students may move into data, finance or technology roles; no licences available |
| R (base R, plus lmtest and sandwich later) | Free; regression is one short line; strong for statistics and graphics | Error messages can be cryptic; robust standard errors need extra packages | Your department already teaches statistics in R |
| Stata | Short, readable commands; robust standard errors are one option; very common in applied economics research | Licence cost; usually tied to lab machines | Your institution has site licences and students are heading to applied economics or policy work |
| Google Colab (Python in the browser) | Zero installation; works on any laptop with a browser and a Google account; notebooks are easy to share | Needs a reliable internet connection; uploaded files disappear when the session ends | Students use their own devices, or IT cannot install software in time |
A 60-minute plan for your first econometrics lab
The plan below assumes one hour, one small dataset, and students working in pairs at one machine. Pairs work well for a first lab: one types, one reads the instructions aloud, and they swap halfway. It also halves the number of machines you need to help.
| Time | Phase | What students do | What you do |
|---|---|---|---|
| 0–5 min | Hook | Answer one question on paper: “Does an extra year of education raise wages? By how much?” | Take three guesses; write them on the board to return to at the end |
| 5–15 min | Get running | Open the software or Colab; run a single line that prints “Hello” or 2 + 2 | Walk the room; fix logins and installs before any data appears |
| 15–25 min | Meet the data | Enter or load the 10-row dataset; print it; produce summary statistics and a scatter plot | Ask: what is one observation? What are the units of each variable? |
| 25–40 min | First regression | Run the regression of wage on education; find the slope, its standard error, t and R² in the output | Project the output; annotate it live with the class |
| 40–50 min | Interpret and predict | Write one sentence interpreting the slope; predict the wage at 16 years of education | Check sentences for units and the words “on average” and “associated with” |
| 50–57 min | Stretch task | Faster pairs re-run with robust standard errors and compare | Support pairs still finishing the core task |
| 57–60 min | Exit ticket | Answer: “What does the standard error of the slope tell you?” | Collect and use the answers to plan the next lecture |
The first ten minutes contain no econometrics on purpose: login and software problems are far easier to fix when nothing else is happening. If a pair is not running by minute 15, move them to Colab rather than debugging an installation in front of the class.
The first regression: one dataset, three languages
Use a dataset small enough to read on one screen. Ten rows is ideal for the first lab: students can see every observation, spot the pattern by eye, and check that the regression line fits what they see. Here is a made-up teaching dataset of ten workers, with years of education and hourly wage in dollars.
| Worker | educ (years) | wage ($ per hour) |
|---|---|---|
| 1 | 10 | 8.20 |
| 2 | 11 | 9.10 |
| 3 | 12 | 10.40 |
| 4 | 12 | 9.60 |
| 5 | 13 | 11.80 |
| 6 | 14 | 12.10 |
| 7 | 14 | 13.50 |
| 8 | 16 | 15.20 |
| 9 | 16 | 14.00 |
| 10 | 18 | 17.90 |
This is illustrative teaching data, not a real sample (mean education 13.6 years, mean wage $12.18).
Python (works in Google Colab as it stands)
import pandas as pd
import statsmodels.formula.api as smf
df = pd.DataFrame({
"educ": [10, 11, 12, 12, 13, 14, 14, 16, 16, 18],
"wage": [8.2, 9.1, 10.4, 9.6, 11.8, 12.1, 13.5, 15.2, 14.0, 17.9]
})
print(df.describe())
model = smf.ols("wage ~ educ", data=df).fit()
print(model.summary())
R
df <- data.frame(
educ = c(10, 11, 12, 12, 13, 14, 14, 16, 16, 18),
wage = c(8.2, 9.1, 10.4, 9.6, 11.8, 12.1, 13.5, 15.2, 14.0, 17.9)
)
summary(df)
model <- lm(wage ~ educ, data = df)
summary(model)
Stata
clear
input educ wage
10 8.2
11 9.1
12 10.4
12 9.6
13 11.8
14 12.1
14 13.5
16 15.2
16 14.0
18 17.9
end
summarize
regress wage educ
What the output says
We ran the Python code above on this dataset. The key lines of the statsmodels output are:
coef std err t P>|t|
-------------------------------------------------------
Intercept -3.9326 1.132 -3.476 0.008
educ 1.1848 0.082 14.455 0.000
R-squared: 0.963 No. Observations: 10
R and Stata report the same coefficients, standard errors, t statistics and R² (R shows “Multiple R-squared: 0.9631”; Stata shows “R-squared = 0.9631”). Here is how to walk students through each number.
| Output | Value | What to tell students |
|---|---|---|
| Slope coefficient on educ | 1.1848 | In this sample, each extra year of education is associated with an hourly wage about $1.18 higher, on average. |
| Intercept | −3.9326 | The predicted wage at zero years of education. It is negative and meaningless here, because nobody in the data has fewer than 10 years. A good moment to discuss extrapolation. |
| Standard error of the slope | 0.082 | How much the slope estimate would vary from sample to sample. Smaller means a more precise estimate. |
| t statistic | 14.455 | The coefficient divided by its standard error (1.1848 / 0.0820 ≈ 14.46). It tests the null hypothesis that the true slope is zero. |
| p-value | 0.000 (shown rounded) | Far below 0.05, so we reject the null of no relationship at any usual level. It is small, not exactly zero. |
| R² | 0.963 | About 96% of the variation in wages in this sample is explained by education. Real wage data give a much lower R², because many other things affect pay. |
Common student errors on the day, and how to fix them
Every lab produces the same handful of problems. If you name them before students meet them, they become routine rather than frightening. Put this table on a slide or print it on the back of the lab sheet.
| Problem | What students see | Fix in Python | Fix in R | Fix in Stata |
|---|---|---|---|---|
| File path | “File not found” or “cannot open file” | Upload the file in Colab’s Files panel, or check the working folder with os.getcwd() | Use getwd() and setwd(), or an RStudio project | Use pwd and cd, or open Stata by double-clicking a do-file in the data folder |
| Missing values | Fewer observations than expected, with no warning | Check the reported “No. Observations” and use df.isna().sum() | Check the degrees of freedom line; use colSums(is.na(df)) | Check “Number of obs”; use misstable summarize |
| Category treated as a number | One strange coefficient on a variable like region coded 1–4 | Write C(region) in the formula | Convert with factor(region) | Use i.region in the regression |
| Default standard errors | Output assumes constant error variance | .fit(cov_type=”HC1″) | coeftest(model, vcov = vcovHC(model, type = “HC1”)) with lmtest and sandwich | regress wage educ, robust |
Missing values deserve special attention, because the software does not stop: statsmodels, lm and regress all drop incomplete rows and report results on the smaller sample. Make “check N” a habit from the first week.
On robust standard errors, one detail catches teachers out. Stata’s robust option and Python’s HC1 use the same small-sample correction, but R’s sandwich package defaults to a different version (HC3) unless you ask for HC1. If students compare outputs across languages, tell them to specify type = “HC1” in R. On our ten-row dataset, the HC1 robust standard error of the slope is 0.073, compared with 0.082 for the default.
What is inside the Econometrics Teacher Pack
- 20 chapters, each with two lesson plans: Lesson 1 is a taught class and Lesson 2 is a computer lab (40 lesson plans in all).
- 473 editable slides, including Python code with real output and R and Stata equivalents.
- Companion datasets and code to run in the lab.
- 20 worksheets, 20 tests and 60 exit tickets, plus mid-year and end-of-year exams (80 marks each).
- A 28-week, two-semester scheme of work mapped to Wooldridge (7th edn) and Stock and Watson (4th edn), plus a teacher guide and an 84-diagram bank.
- A real published study in every chapter, such as Card and Krueger (1994), Angrist and Krueger (1991) and Duflo (2001), with the textbook (589 pages) and practice book (1,161 worked questions) included.
Assessing lab work: short write-ups and reproducibility
Lab work is easy to over-assess. A ten-page report for every session will exhaust you and teach students that labs are about formatting. A better model is a short write-up after each lab, marked against a small number of clear criteria, with the code handed in alongside it.
Here is a one-page template that works well from the first lab onwards.
| Section | Length | What you look for |
|---|---|---|
| Question | 1–2 sentences | A clear economic question, for example “How is education related to hourly wages?” |
| Data | 2–3 sentences | What one observation is, the sample size actually used in the regression, and any missing values dropped |
| Results | A small table | Coefficient, standard error, N and R², with units |
| Interpretation | 3–4 sentences | The slope in plain English with units and “on average”; a comment on precision or significance |
| Limitation | 2 sentences | One reason the estimate may not be causal, such as an omitted variable |
Alongside the write-up, ask for the script (a .py file or notebook, an .R script, or a Stata do-file). The test of reproducibility is simple: you, or a classmate, can run it from top to bottom on a fresh session and get the same numbers as the write-up. Make this worth a small fixed share of the marks every week. It costs little to check, and it builds the single most useful professional habit in applied work.
Progressing from the first lab: robust SEs, dummies, IV and DiD
Once students can run and read one regression, every later lab adds one new idea to the same routine: load, check, regress, interpret, write up. The sequence below follows the order of most first courses built on Wooldridge or Stock and Watson[1][2].
| Stage | New idea | Python | R | Stata |
|---|---|---|---|---|
| Robust standard errors | Inference that does not assume constant error variance | .fit(cov_type=”HC1″) | coeftest(model, vcov = vcovHC(model, type = “HC1”)) | regress y x, robust |
| Multiple regression | Holding other factors constant; omitted variable bias | “wage ~ educ + exper” | lm(wage ~ educ + exper, data = df) | regress wage educ exper |
| Dummy variables | Group differences and the base category | “wage ~ educ + C(female)” | lm(wage ~ educ + factor(female), data = df) | regress wage educ i.female |
| Instrumental variables | Using an instrument for an endogenous regressor | IV2SLS.from_formula(“y ~ 1 + [x ~ z]”, df) in linearmodels | ivreg(y ~ x | z, data = df) from the ivreg or AER package | ivregress 2sls y (x = z), robust |
| Difference-in-differences | Comparing changes for treated and control groups | “y ~ treat * post” | lm(y ~ treat * post, data = df) | regress y i.treat##i.post, robust |
The last two rows are where your course connects with real research. Instrumental variables can be taught with the quarter-of-birth design of Angrist and Krueger (1991); difference-in-differences comes alive with Card and Krueger’s (1994) study of the minimum wage in New Jersey and Pennsylvania fast-food restaurants. Both are discussed at length in Mostly Harmless Econometrics[3], which is a valuable reference for the teacher even if it is beyond most first-year students. Using real studies in the lab is a direct answer to Angrist and Pischke’s call for more research design and causal questions in undergraduate econometrics[4].
How the Econometrics Teacher Pack’s Lesson 2 labs work
If you would rather not build every lab from scratch, this is what the Econometrics Teacher Pack is for. Each of its 20 chapters has two 60-minute lesson plans. Lesson 1 is a taught class that introduces the idea. Lesson 2 is a computer lab, where students apply that idea to data.
The slides for the labs include Python code with its real output, so you can show exactly what students should see on screen, together with R and Stata equivalents for departments that use those tools. Companion datasets and code are included, so the lab is ready to run rather than ready to adapt. Each chapter is built around a real published study, such as Card and Krueger (1994), Angrist and Krueger (1991) and Duflo (2001), which lets the lab follow the research-design approach discussed above.
Every document is editable Word or PowerPoint plus print-ready PDF, licensed for one teacher or one school department.
Your first econometrics lab does not need to be ambitious. One small dataset, one regression, one clear sentence of interpretation and a script that runs from top to bottom is a very good first hour. If you would like the rest of the term’s labs ready to go, take a look at the Econometrics Teacher Pack, or download the free sample first to see how the taught lessons and computer labs fit together.
Frequently asked questions
Do my students need to install anything for the first lab?
Not if you use Google Colab. Students need only a browser and a Google account, and the Python code in this post runs in a Colab notebook as it stands. If your computer room has R, RStudio or Stata installed, check that every machine opens the software before the session, ideally the day before.
Which language should I choose if I can only teach one?
Choose the one your department can support. Python suits students heading towards data and industry roles, R suits departments that already teach statistics in it, and Stata suits applied economics where licences are available. The econometrics is identical in all three, so students who learn one can move to another later.
I am not a confident coder. Can I still run an econometrics lab?
Yes. The first labs use a handful of commands, and you need to recognise the common errors far more than you need to write elegant code. Run the lab yourself from start to finish on a student machine beforehand, keep the error-fix table above to hand, and let confident students help their neighbours.
How long before students can run a regression on their own?
That varies with the group, but a sensible aim is for most pairs to load a dataset, run a regression and interpret the slope without help after a few labs, provided each lab repeats the same routine and adds only one new idea.
References
- Wooldridge, J. M. (2020) Introductory Econometrics: A Modern Approach, 7th edn. Boston, MA: Cengage. cengage.com
- Stock, J. H. and Watson, M. W. (2020) Introduction to Econometrics, 4th edn. New York: Pearson. pearson.com
- Angrist, J. D. and Pischke, J.-S. (2009) Mostly Harmless Econometrics: An Empiricist’s Companion. Princeton, NJ: Princeton University Press. doi.org/10.1515/9781400829828
- Angrist, J. D. and Pischke, J.-S. (2017) “Undergraduate Econometrics Instruction: Through Our Classes, Darkly”, Journal of Economic Perspectives, 31(2), pp. 125–144. doi.org/10.1257/jep.31.2.125
- GAISE College Report ASA Revision Committee (2016) Guidelines for Assessment and Instruction in Statistics Education College Report 2016. Alexandria, VA: American Statistical Association. amstat.org

