Semester 4Economics

Specialisation B: Data Analytics for Economics crash course, Online MA, Semester 4:

This subject covers advanced econometric methods for causal analysis, including panel data models, instrumental variables and difference-in-differences, along…

  • 4 Short Videos
  • 28 mins per video
  • 20 Quiz Questions
  • Study Notes
  • Assignment

4 lessons in Specialisation B: Data Analytics for Economics

Each lesson pairs one topic with a hand-picked video, trimmed to the part that teaches it.

About this subject

This subject covers advanced econometric methods for causal analysis, including panel data models, instrumental variables and difference-in-differences, along with an introduction to machine learning for economic data. After it, you will be able to derive and apply these estimators, interpret their diagrams, and solve numerical problems on real economic datasets.

  1. 1

    Panel Data Models: Fixed and Random Effects

    Module 1, Advanced Econometrics and ML: Panel data

    Panel Data Models

    econometricsacademy · 63 min

    Study notes 5 quiz questionsWatch lesson
  2. 2

    Instrumental Variables and 2SLS

    Module 1, Advanced Econometrics and ML: instrumental variables

    An intuitive introduction to Instrumental Variables

    Doug McKee · 19 min

    Study notes 5 quiz questionsWatch lesson
  3. 3

    Difference-in-Differences Estimation

    Module 1, Advanced Econometrics and ML: difference-in-differences

    An intuitive introduction to Difference-in-Differences

    Doug McKee · 13 min

    Study notes 5 quiz questionsWatch lesson
  4. 4

    Machine Learning Basics for Economists

    Module 1, Advanced Econometrics and ML: machine learning basics

    All Machine Learning algorithms explained in 17 min

    Infinite Codes · 16 min

    Study notes 5 quiz questionsWatch lesson

Assignment

Applied Econometrics Problem Set: Panel Data, IV, DiD and ML Choices

Free login to open
Exam cheatsheetSpecialisation B: Data Analytics for Economics on two pagesKey points, formulas and tables for quick revision

Go beyond the syllabus

Free step-by-step roadmaps that take Specialisation B: Data Analytics for Economics towards a job.

Specialisation B: Data Analytics for Economics notes

Study notes for every lesson of Specialisation B: Data Analytics for Economics (Online MA, Semester 4): the main points, key terms and takeaways, lesson by lesson.

Specialisation B: Data Analytics for Economics: complete notes PDF

All 4 lessons’ study notes in one PDF, with a contents page. Free after you log in.

Lesson 1

Panel Data Models: Fixed and Random Effects

Panel data follow the same individuals or firms over time, so each variable can vary both between individuals and within individuals over time. The estimators covered are pooled OLS, between, first-difference, fixed effects (within or dummy-variable) and random effects. They differ in how they treat the unobserved individual-specific effect a_i, and the Hausman test is used to choose between fixed and random effects.

Types of variables and variation

  • Time-varying regressors x_it change across both individuals and time (e.g. annual income, monthly food spending).
  • Time-invariant regressors have x_it = x_i for every t (e.g. gender, race).
  • Individual-invariant regressors have x_it = x_t for every i (e.g. a time trend, the national unemployment rate).
  • Overall variation is x_it - x̄. Between variation is x̄_i - x̄. Within variation is x_it - x̄_i, which removes each individual's level.

Pooled OLS, between and first-difference estimators

  • Pooled OLS: y_it = b0 + b1 x1_it + b2 x2_it + u_it is estimated on all n*T observations and ignores the panel structure.
  • Between estimator: regresses the individual means ȳ_i on x̄_i, uses only n observations and is rarely used.
  • Model with an individual effect: y_it = b0 + b1 x_it + a_i + u_it, where a_i captures unobserved factors specific to each individual.
  • a_i may be correlated with the regressors (e.g. ability and education). Leaving it in the error term then biases the estimates.
  • First difference: regress Δy_it on Δx_it with n(T-1) observations. a_i cancels out, but time-invariant variables drop out as well.

Fixed effects

  • Within transformation: subtract each individual's time mean from every variable (time-demeaning), so a_i drops out. Then estimate by OLS.
  • The individual effects can be recovered afterwards: a_i = ȳ_i - b·x̄_i.
  • The dummy-variable regression includes a dummy for each individual (dropping one as the reference). It gives the same slope coefficients as the within estimator.
  • Time-invariant variables cannot be included because they are perfectly collinear with the fixed effects.
  • The within R-squared explains only within variation, while the dummy-variable R-squared is much higher because the dummies absorb between variation.
  • With T = 2, fixed effects and first differences give identical estimates. With T > 2, first differences can be better if the errors are serially correlated.

Random effects and model choice

  • Random effects assume a_i is uncorrelated with the regressors. The composite error a_i + u_it is then serially correlated within each individual.
  • Pooled OLS is still consistent in this case but inefficient. Random effects uses a quasi-demeaning transformation: y_it - θ ȳ_i.
  • θ = 1 - sqrt(σu² / (σu² + T σa²)).
  • θ close to 0 gives roughly pooled OLS (a_i unimportant). θ close to 1 gives roughly fixed effects (a_i important).
  • Random effects can include time-invariant variables.
  • Hausman test: use it to choose between fixed effects and random effects.

Key terms

Panel data
Repeated observations on the same units over several time periods.
Individual-specific effect a_i
An unobserved, time-constant factor that shifts an individual's outcome.
Within transformation
Subtracting each individual's time average from every variable.
First-difference estimator
OLS on period-to-period changes, which removes a_i.
Random effects
An estimator that assumes a_i is uncorrelated with the regressors and uses quasi-demeaning by θ.
Hausman test
A test used to choose between the fixed effects and random effects estimators.

Lesson 2

Instrumental Variables and 2SLS

When a regressor such as education is correlated with the error term, OLS is biased. Instrumental variables (IV) solve this by using only the variation in the endogenous regressor that is driven by an instrument, which must be relevant and must affect the outcome only through the regressor. Two-stage least squares (2SLS) puts this into practice.

The endogeneity problem

  • Wage equation: log(wage) = b0 + b1 educ + b2 exper + b3 exper² + e.
  • Ability, persistence, health and social networks affect wages and are also correlated with schooling.
  • Because these factors are unobserved, education is endogenous and the OLS estimate of b1 is biased.
  • IV corrects for this without needing to measure the confounders.

What makes a good instrument

  • Relevance: the instrument Z must be correlated with the endogenous regressor.
  • Exclusion (validity): Z affects the dependent variable only through the regressors, so Z must be independent of the error term.
  • Distance to the nearest college is relevant. It is valid only if labor markets near colleges are not otherwise different.
  • Quarter of birth affects schooling through compulsory schooling laws but is only weakly correlated with education. Bound, Jaeger and Baker found first-stage F statistics of 2.4 and 1.87.

Two-stage least squares

  • Stage 1: regress educ on Z and the exogenous regressors, then compute fitted values educ-hat.
  • educ-hat is a linear combination of exogenous variables, so it is uncorrelated with the error term.
  • Stage 2: regress log(wage) on educ-hat and the other regressors. This gives a consistent estimate of b1.
  • Card (1993) used college proximity as the instrument: growing up near a college added about 0.3 years of schooling, and the IV return to schooling was about 13.2% per year.
  • Running the two stages manually gives the correct point estimates but wrong standard errors. Use a built-in IV command (e.g. Stata's ivregress).

Cautions

  • Weak instruments: the first-stage F test on the instruments should be at least 10, preferably 12 or more.
  • Several instruments can be used together if each one is valid.
  • IV estimates a local average treatment effect (LATE): the effect for the people whose treatment is changed by the instrument.
  • Validity is hard to test. With more than one instrument, overidentification tests (Sargan, Hausman) check whether the instruments give similar estimates.

Key terms

Endogenous regressor
A regressor that is correlated with the error term.
Instrument
A variable correlated with the endogenous regressor that affects the outcome only through the regressors.
2SLS
An estimator that regresses the endogenous variable on the instruments, then uses the fitted values in the main regression.
Weak instrument
An instrument with low first-stage correlation (F below 10), which makes IV estimates unreliable.
LATE
The average treatment effect for the subgroup whose treatment is shifted by the instrument.

Lesson 3

Difference-in-Differences Estimation

Difference-in-differences (DiD) estimates a program's causal effect by comparing the before-after change in a treated group with the before-after change in an untreated control group. It relies on the parallel trends assumption: without the program, both groups would have changed by the same amount. DiD can be computed from four group means or, equivalently, as the interaction coefficient in a regression.

Intuition and setup

  • Used when a program was not randomized and outcomes are observed for a treated and a control group, both before and after implementation.
  • Example: free school lunch in Sao Paulo (treated) from 2009; Rio (control); math test scores in 2008 and 2010.
  • D1 = change over time in treated group = program effect + time trend (e.g., a soccer tournament in 2008 affecting scores).
  • D2 = change over time in control group = estimate of the trend.
  • DiD = D1 - D2.
  • Equivalently: D3 = treated minus control in post period (effect + area differences); D4 = treated minus control in pre period (area differences); DiD = D3 - D4. Both versions are algebraically identical.

When to use DiD vs alternatives

  • Random assignment: simple treatment-control difference is unbiased; DiD may still improve precision.
  • Simple before-after difference only works if nothing else changed over time - rarely reasonable.
  • If assignment depends only on observables, multiple regression with controls works.
  • DiD helps when assignment and other group differences are unknown.
  • Worked example: Sao Paulo scores rose 70, Rio rose 40, so DiD = 70 - 40 = 30 points.

Regression form

  • Y = b0 + b1*Post + b2*Treat + b3*(Post x Treat) + error.
  • E[Y | control, pre] = b0; E[Y | treated, post] = b0 + b1 + b2 + b3.
  • Control change over time = b1; treated change = b1 + b3; DiD = b3, the interaction coefficient.
  • Works with aggregate data, repeated cross-sections, or panel (longitudinal) data; individual data allows more flexible models.
  • Reasons to use regression: automatic standard errors; can add controls X (e.g., socioeconomic status) for differing trends; controls reduce error variance and shrink standard errors.

Validity: parallel trends

  • Pre-existing level differences between groups are fine (e.g., Sao Paulo chosen because kids were worse off).
  • Invalid if trends unrelated to the program differ, e.g., Rio gets its own lunch program at the same time.
  • If either D2-as-trend or D4-as-stable-gap assumption seems doubtful, the DiD estimate is suspect.

Key terms

Difference-in-differences
Change over time in the treated group minus change over time in the control group.
Parallel trends assumption
Absent treatment, treated and control groups would have followed the same trend over time.
Interaction term
Product Post x Treat in the DiD regression; its coefficient is the DiD estimate.
Repeated cross-section
Separate samples drawn in each period and group.
Longitudinal (panel) data
Data observing the same individuals in both periods.

Lesson 4

Machine Learning Basics for Economists

Machine learning develops algorithms that learn from data and generalize to unseen data. It splits into supervised learning (regression and classification with labeled data) and unsupervised learning (finding structure such as clusters or lower-dimensional representations without labels). Key algorithms range from linear regression to ensembles and neural networks.

Supervised vs unsupervised

  • Supervised: features (inputs) predict a target with known labels in training data.
  • Regression predicts a continuous target (house price); classification predicts a discrete class (spam/not spam).
  • Unsupervised: no labels; find structure, e.g., clustering emails into unspecified groups.

Core supervised algorithms

  • Linear regression: fits a line minimizing sum of squared errors; basis for many advanced methods.
  • Logistic regression: fits a sigmoid to give class probabilities.
  • KNN: non-parametric; predicts average/majority of K nearest neighbors. Small K overfits, very large K underfits; K is a hyperparameter tuned e.g. by cross-validation.
  • SVM: finds decision boundary (hyperplane) with maximum margin; support vectors lie on margin edge; kernels (linear, polynomial, RBF, sigmoid) give nonlinear boundaries via implicit feature engineering; strong in high dimensions.
  • Naive Bayes: uses Bayes' theorem assuming independent features; fast, good for text/spam.

Trees, ensembles and neural networks

  • Decision tree: series of yes/no splits aiming for pure leaves.
  • Bagging: train models on bootstrap samples; random forest = many trees voting, with random feature exclusion to decorrelate trees.
  • Boosting: models trained in sequence, each fixing previous errors (AdaBoost, gradient boosting, XGBoost); often more accurate but more overfitting-prone and slower.
  • Neural networks: hidden layers learn hidden features automatically; many layers = deep learning.

Unsupervised methods

  • K-means: pick K random centers, assign points to nearest, recompute centers, repeat until stable.
  • Other clustering: hierarchical, DBSCAN (no K needed, arbitrary shapes).
  • Dimensionality reduction: PCA finds orthogonal directions of maximum variance; drop low-variance components.

Key terms

Feature
Input/independent variable used for prediction.
Label
Known true value of the target in training data.
Hyperparameter
Setting chosen before training, like K in KNN or K-means.
Overfitting
Fitting training data too closely so the model generalizes poorly.
Ensemble
Combining many simple models into a stronger one (bagging, boosting).
Principal component
Direction capturing maximal remaining variance in the data.
Every crash course

NOT just videos. Everything you NEED to pass.

Watch videos for FREE. Simplified notes, quizzes and assignments. Stuck? Ask a senior or alumni.

  • Free

    Hand-picked video lessons

    Short lessons hand picked by seniors and alumni, trimmed to just what you need.

  • Free login

    Study notes

    Summary, key points and key terms for every lesson. Revise in minutes.

  • Free login

    Quizzes

    Quick checks after each lesson. See the right answer, and why, instantly.

  • Free login

    Assignments

    Practice tests and questions for every subject, based on what your exam asks.

  • Free login

    Notebook

    Write notes for any video at any second. Go back to the note anytime you want.

  • Free login

    Saved progress

    Lessons, scores and where you left. Synced on every device.

  • Live chat pass

    LIVE chat

    Members ONLY chat for all doubts, tips and memes with students from your degree.

  • Per-minute chat

    Ask an Insider

    1:1 instant chat or call with verified seniors from your degree. Ask anything and everything.

Members only

Online MA Insiders Club. Study together, LIVE.

LIVE chat with other Online MA students right beside the video. Ask doubts mid-lessons, share tips, or celebrate a finished semester.

  • LIVE chats for every lesson
  • Doubt Solving by Seniors and Alumni.
  • Members ONLY Stickers and GIFs
  • Premium access to study groups
Open LIVE chat

*Instant refund. NO questions asked.*

Pass₹19
Learn from seniors

Stuck on Specialisation B: Data Analytics for Economics? Ask someone who’s done it.

Talk to MA insiders

Verified seniors from MA. Ask about exams, subjects or placements.

Frequently asked questions

This MA 4th semester course covers 4 topics, one video lesson each: Panel Data Models: Fixed and Random Effects, Instrumental Variables and 2SLS, Difference-in-Differences Estimation and Machine Learning Basics for Economists.

Every lesson has free study notes in English and Hinglish under its video. Log in to download them as a PDF.

These are free video courses handpicked by seniors and alumni. Each lesson has one video for each subject of your degree and semester.

YES, all videos are free with no sign-up required. You can login to unlock study notes, quizzes, and assignments.

It covers all degrees and their specialisations, including short video lessons for each subject, semester by semester.

A LIVE chat beside every lesson where Online MA students ask doubts and share tips. You only pay ₹19 once to unlock live chat for every degree.

NO. The videos are in Hinglish and easy to understand.

A FREE log-in is required to save your progress across all devices.

NO. InsideEdge isn’t affiliated with any Online University. These crash courses are handpicked by seniors and alumni to help you understand and revise faster, alongside your official study material.