ECON 2041

Introductory Econometrics

Get using Python

Plan for the semester

1 What is econometrics?

2 Basic mathematical tools

3 Stats fundamentals

4 Stats fundamentals II

5 Simple regression

6 OLS properties & fit

7 Flavors of OLS & OVB Quiz

8 Causality

9 Regression inference

10 Inference, continued PS due 16 Oct

11 Diagnostics

12 Measurement error & IRL

13 Revision

Plan for today

  • Why you should learn to code
  • What is Python & why are we using it?
  • Setting up Google Colab
  • Python basics

The elephant
in the
(class)room

Image generated using Adobe Express (Premium)
Prompt: elephant in the classroom

What’s your background?

Quick survey on your background & interests


  1. Open your portal link
    https://emiliatjernstrom.com/econ2041/portal.html

    OR scan the QR code, then enter your code
  2. Answer the five questions and hit Submit


Portal answers are anonymous & ungraded

Why you should still learn to code

… even though AI can (sort of) do it for you

Coding builds core transferable skills

  • teaches problem solving
  • sharpens logic & structure
  • trains you to check & debug

Why you should still learn to code

… even though AI can (sort of) do it for you

Coding builds core transferable skills

  • teaches problem solving
  • sharpens logic & structure
  • trains you to check & debug

Coding makes you stand out

  • signals technical fluency
  • shows initiative & curiosity
  • you will do more than peers who rely on AI


AI can’t replace understanding

  • AI guesses but you still need to judge
  • bad code may still run
  • without knowing the basics you can’t fix errors

Why you should still learn to code

… even though AI can (sort of) do it for you

Coding builds core transferable skills

  • teaches problem solving
  • sharpens logic & structure
  • trains you to check & debug

Coding makes you stand out

  • signals technical fluency
  • shows initiative & curiosity
  • you will do more than peers who rely on AI


AI can’t replace understanding

  • AI guesses but you still need to judge
  • bad code may still run
  • without knowing the basics you can’t fix errors

What is Python?

Python!

We’ll use Python & Jupyter notebooks for our econometric data work

Python is…

one of the most popular programming languages

Python!

We’ll use Python & Jupyter notebooks for our econometric data work

Python is…

a free & open-source general-purpose programming language

used for

  • AI
  • scientific computing
  • communication
  • web development
  • CGI and graphical user interfaces
  • game development
  • etc.

Python!

We’ll use Python & Jupyter notebooks for our econometric data work

Python is…

a free & open-source general-purpose programming language

used by

  • Google
  • OpenAI
  • Netflix
  • Meta
  • Dropbox
  • Amazon
  • Reddit
  • etc.

Jupyter notebooks

We’ll use Python & Jupyter notebooks for our econometric data work

Jupyter notebooks: one of the many ways of interacting with Python


They let you use your browser to

  • write & execute Python commands
  • format output, including tables, figures, animations, etc.
  • combine text, mathematical expressions, and code

Jupyter notebooks

We’ll use Python & Jupyter notebooks for our econometric data work

Jupyter notebooks: one of the many ways of interacting with Python


Jupyter isn’t the only way to code in Python, but it’s GREAT for

  • getting started coding in Python
  • testing new ideas
  • interacting with small pieces of code
  • using online interactive environments such as Google Colab
  • sharing / collaborating on research

We work in Colab

Everything in this unit runs in Google Colab,
in your browser

  • nothing to install
  • works on any machine you sit at
  • your work saves to your Google Drive

Google Colab

Colab allows you to run Python (in a Jupyter notebook)
on a Google-provided remote cloud computer


Amazingly, this is free but it does require a Google account

One cool feature of this is that you can run it from your smartphone

Over to the notebook

Open this week’s lecture notebook and follow along:


https://emiliatjernstrom.com/econ2041/lectures/w02


It will open directly in Colab

Click Copy to Drive first, so your edits save

Now you know…

  • How to open and run a Jupyter notebook
  • How to get Python to print something for you
  • How to use Python as a calculator




I hope you’re excited about applying these skills
and building on them!