Using Jupyter to Teach and Assess Econometrics

Marina Adshade

Vancouver School of Economics UBC

Jonathan Graves

Vancouver School of Economics UBC

Emrul Hasan

Vancouver School of Economics UBC

2024-06-19

Pitch: A Common Situation

Have you ever:

  • Wanted to show students some cool patterns in data?
  • Needed to teach students how to do basic coding?
  • Tried to demonstrate a new econometric technique or something?

This is a major learning context in any course which deals with or teaches data and computation.

Problem

However, this is way harder to do than it should be:

  • Your students need computers that can run the material…
  • They need to have the right software…
  • They need to know how to use it: maybe code in it?
  • You need to share the learning materials with them.

These are all major points of failure.

Introduction

In this talk, I will discuss our work developing interactive Jupyter notebooks to help students learn applied econometrics.

Our open-source project: COMET comet.arts.ubc.ca

Outline

  1. What are Jupyter Notebooks?
    • What are some alternatives?
    • What are the advantages?
  2. How can I use them to teach econometrics?
    • What is our project?
    • What are some strategies for using them?
  3. How can I use them for assessment?

What is a Notebook?

A notebook is a digital document which combines rich text (including hyperlinks, formatting, and images) with cells that can perform computations. Examples include:

  • Jupyter Notebooks
  • RMarkdown Notebooks
  • Observable or D3.js

Key Feature: a user is able to interact with the content of a notebook, such as performing a computation or changing the text.

An example of a Jupyter notebook

Why Notebooks?

Notebooks teach economics students three important skills:

  1. Literate programming. Popular framework for data analysis (Knuth (1984)), and creates self-documenting tools that address common problems novice (and experienced) researchers face when analyzing data (Kery et al. (2018)).

  2. Replicable and reproducible data analysis (Camerer et al. (2018)). Notebooks encourage replicable programming practices by design, and transparency with experimentation.

  3. Industry-relevant. Notebooks are extensively used by employers who conduct data science research, or who use data science in their work.

Creating notebooks for classroom instruction turns them from a research tool into a pedagogical tool.

What is Jupyter?

Project Jupyter is on open-source project to support interactive data science and scientific computing.

  • Users connect to a central server, called a JupyterHub, which runs kernels that perform computations.
    • Or: users can run the server locally on their own PC.
  • Users interact with the notebooks by editing or running cells which contain different kinds of content.

Interactive areas in a Jupyter notebooks

Why Jupyter?

Jupyter has some advantages for teaching not shared by alternatives:

  1. No installation necessary when used through a JupyterHub, Jupyter notebooks do not require install any software or a powerful computer.
  2. Simple Github integration: through nbgitpuller starting a class is as easy as sharing a link.
  3. Language independence: computational kernels available for all major languages (R, STATA, Python, Julia, etc.)

Public or Free Hubs

Where do you find a hub? You have options:

You can also set up your own, or work with non-profits like 2i2c to develop your own hub.

What are the Alternatives?

Jupyter Notebooks are not the only option for teaching using notebooks and there can be advantages to other notebook formats:

Note: these formats can be converted back and forth.

How to Use for Teaching?

We have tried several ways of teaching using Jupyter Notebooks, and found that they fit most teaching styles. We have found them particularly effective in:

  • Lecture.
  • Flipped classrooms.
  • Workshops or labs.

However, the way you use them and the design of the notebooks differ.

Lecture and Demonstrations

Jupyter notebooks are most effective in lecture when you use them as a demonstration tool which students can follow along:

  • The power of a Jupyter notebook is the interactive nature of the different cells.
  • This allows you to enhance your lecture by running cells and changing their values to demonstrate principles.

Example

  • Try demonstrating a cell, then asking students to predict what happen when you make a different change. Then do it!
  • This works great with classroom response systems such as iClicker or TopHat.

Workshops, Labs, and Flipped Classrooms

“Flipping” (Akçayır and Akçayır (2018)) the lecture demonstration, as discussed, using Jupyter Notebooks is a natural fit.

  • The interactivity of notebooks makes them ideal for setting as a “pre-reading” assignment.
  • You can also embed interactive “self-tests” into the notebook, to check student understanding (and completion)
  • In class, you can then do a more complex example or application.

This also works well for small workshops, TA-led labs, or self-study.

Assessment

Jupyter Notebooks also make effective assessments:

  • Self-tests, combined with hash functions, make good assignments or exams.
  • We have used a custom JupyterHub with a Lockdown Browser to carry out computational exams in a “bring your own device” set-up.
    • Can be set-up to distribute and collect exams.
    • Works well with Chromebook-based computer labs.

There are also Jupyter-based assessment systems such as nbgrader or ottergrader.

Further Reading

  • All of our teaching and learning materials are free and open-source.
  • You can find a copy of this presentation and all the links on our website.
  • If you want to get involved or collaborate send me an email:

References

Akçayır, Gökçe, and Murat Akçayır. 2018. “The Flipped Classroom: A Review of Its Advantages and Challenges.” Computers & Education 126: 334–45.
Camerer, Colin F, Anna Dreber, Felix Holzmeister, Teck-Hua Ho, Jürgen Huber, Magnus Johannesson, Michael Kirchler, et al. 2018. “Evaluating the Replicability of Social Science Experiments in Nature and Science Between 2010 and 2015.” Nature Human Behaviour 2 (9): 637–44.
Kery, Mary Beth, Marissa Radensky, Mahima Arya, Bonnie E John, and Brad A Myers. 2018. “The Story in the Notebook: Exploratory Data Science Using a Literate Programming Tool.” In Proceedings of the 2018 CHI Conference on Human Factors in Computing Systems, 1–11.
Knuth, Donald Ervin. 1984. “Literate Programming.” The Computer Journal 27 (2): 97–111.