Skip to content

metricsAI: An Introduction to Econometrics with Python and AI in the Cloud

Notifications You must be signed in to change notification settings

quarcs-lab/metricsai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

168 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

metricsAI: An Introduction to Econometrics with Python and AI in the Cloud

Welcome to metricsAI!

This data science platform offers a modern introduction to econometrics by combining cloud-based Python notebooks with AI learning tools from NotebookLM.

Designed as an interactive companion to Colin Cameron's textbook, Analysis of Economics Data: An Introduction to Econometrics, metricsAI transforms static chapters into dynamic learning experiences. Students can access AI summaries, Python code, and practical examples directly in their browsers via Google Colab. There is zero setup or installation required, and the notebooks feature built-in AI tools for code generation, explanation, and transformation.

πŸ““ Interactive Google Colab Notebooks

Click any badge below to open and run immediately in your browser. Every chapter includes AI video lectures, AI slides, author slides, quizzes, AI tutors, and audio lectures available on the project website.

Part I: Statistical Foundations

Chapter Title Colab Notebook Additional Resources
1 Analysis of Economics Data Open In Colab 🎬 AI Video β€’ ✨ AI Slides β€’ πŸ“Š Author Slides β€’ πŸ“ Quiz β€’ πŸ€– AI Tutor β€’ 🎧 Audio
2 Univariate Data Summary Open In Colab 🎬 AI Video β€’ ✨ AI Slides β€’ πŸ“Š Author Slides β€’ πŸ“ Quiz β€’ πŸ€– AI Tutor β€’ 🎧 Audio
3 The Sample Mean Open In Colab 🎬 AI Video β€’ ✨ AI Slides β€’ πŸ“Š Author Slides β€’ πŸ“ Quiz β€’ πŸ€– AI Tutor β€’ 🎧 Audio
4 Statistical Inference for the Mean Open In Colab 🎬 AI Video β€’ ✨ AI Slides β€’ πŸ“Š Author Slides β€’ πŸ“ Quiz β€’ πŸ€– AI Tutor β€’ 🎧 Audio

Part II: Bivariate Regression

Chapter Title Colab Notebook Additional Resources
5 Bivariate Data Summary Open In Colab 🎬 AI Video β€’ ✨ AI Slides β€’ πŸ“Š Author Slides β€’ πŸ“ Quiz β€’ πŸ€– AI Tutor β€’ 🎧 Audio
6 The Least Squares Estimator Open In Colab 🎬 AI Video β€’ ✨ AI Slides β€’ πŸ“Š Author Slides β€’ πŸ“ Quiz β€’ πŸ€– AI Tutor β€’ 🎧 Audio
7 Statistical Inference for Bivariate Regression Open In Colab 🎬 AI Video β€’ ✨ AI Slides β€’ πŸ“Š Author Slides β€’ πŸ“ Quiz β€’ πŸ€– AI Tutor β€’ 🎧 Audio
8 Case Studies for Bivariate Regression Open In Colab 🎬 AI Video β€’ ✨ AI Slides β€’ πŸ“Š Author Slides β€’ πŸ“ Quiz β€’ πŸ€– AI Tutor β€’ 🎧 Audio
9 Models with Natural Logarithms Open In Colab 🎬 AI Video β€’ ✨ AI Slides β€’ πŸ“Š Author Slides β€’ πŸ“ Quiz β€’ πŸ€– AI Tutor β€’ 🎧 Audio

Part III: Multiple Regression

Chapter Title Colab Notebook Additional Resources
10 Data Summary for Multiple Regression Open In Colab 🎬 AI Video β€’ ✨ AI Slides β€’ πŸ“Š Author Slides β€’ πŸ“ Quiz β€’ πŸ€– AI Tutor β€’ 🎧 Audio
11 Statistical Inference for Multiple Regression Open In Colab 🎬 AI Video β€’ ✨ AI Slides β€’ πŸ“Š Author Slides β€’ πŸ“ Quiz β€’ πŸ€– AI Tutor β€’ 🎧 Audio
12 Further Topics in Multiple Regression Open In Colab 🎬 AI Video β€’ ✨ AI Slides β€’ πŸ“Š Author Slides β€’ πŸ“ Quiz β€’ πŸ€– AI Tutor β€’ 🎧 Audio
13 Case Studies for Multiple Regression Open In Colab 🎬 AI Video β€’ ✨ AI Slides β€’ πŸ“Š Author Slides β€’ πŸ“ Quiz β€’ πŸ€– AI Tutor β€’ 🎧 Audio

Part IV: Advanced Topics

Chapter Title Colab Notebook Additional Resources
14 Regression with Indicator Variables Open In Colab 🎬 AI Video β€’ ✨ AI Slides β€’ πŸ“Š Author Slides β€’ πŸ“ Quiz β€’ πŸ€– AI Tutor β€’ 🎧 Audio
15 Regression with Transformed Variables Open In Colab 🎬 AI Video β€’ ✨ AI Slides β€’ πŸ“Š Author Slides β€’ πŸ“ Quiz β€’ πŸ€– AI Tutor β€’ 🎧 Audio
16 Checking the Model and Data Open In Colab 🎬 AI Video β€’ ✨ AI Slides β€’ πŸ“Š Author Slides β€’ πŸ“ Quiz β€’ πŸ€– AI Tutor β€’ 🎧 Audio
17 Panel Data, Time Series Data, Causation Open In Colab 🎬 AI Video β€’ ✨ AI Slides β€’ πŸ“Š Author Slides β€’ πŸ“ Quiz β€’ πŸ€– AI Tutor β€’ 🎧 Audio

How to Use the Notebooks

  1. Click any "Open in Colab" badge above
  2. Sign in with your Google account (free)
  3. Click "Run All" in the Runtime menu (or run cells individually)
  4. Explore and modify - change parameters, try different models, experiment with the data
  5. Save your work - File β†’ Save a copy in Drive to keep your modifications

No installation, no downloads, no setup required!

πŸ› οΈ Local Development Setup

For local development (not required for Colab usage):

# Clone and set up virtual environment
git clone https://github.com/quarcs-lab/metricsai.git
cd metricsai
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

# Install Playwright browser (for PDF generation only)
playwright install chromium

πŸŽ₯ AI Video Lectures with Modal Player

NEW: Selected chapters now feature AI-generated video lectures available directly on the project website!

Video Player Features

  • In-Page Video Player: Watch videos without leaving the website using an elegant modal overlay
  • Large, Comfortable Viewing: Videos display at optimal size (up to 1152px wide) with responsive 16:9 aspect ratio
  • Auto-Play: Videos start automatically when the modal opens
  • Multiple Close Options: Close videos via X button, Escape key, or clicking outside the video
  • Smart Controls: Video automatically stops playing when modal is closed, preventing background playback

How It Works

  1. Click the 🎬 AI video link in any chapter's resources
  2. Video opens in a modal overlay on the current page
  3. Watch the AI-powered lecture explaining key concepts
  4. Close when done - video stops automatically

Current Coverage: All 17 chapters

The AI videos complement the audio lectures and slides, providing visual explanations of econometric concepts through AI-generated presentations.

πŸ“š Enhanced Educational Chapter Format

All 17 chapters have been transformed into professional, book-style educational chapters following modern pedagogical best practices. Each chapter includes:

Key Features

  1. Visual Summary - Chapter opening image with descriptive caption providing immediate context
  2. "What You'll Learn" - Clear learning objectives in "How to..." format setting expectations upfront
  3. Contextual Introductions - 3-4 sentence paragraphs before every code section explaining:
    • What the code will do
    • Why this analysis matters
    • What method or approach is being used
  4. Concept Boxes - πŸ’‘ Key statistical and econometric concepts highlighted with:
    • Clear definitions
    • Intuitive explanations
    • Practical examples
  5. Conversational Conclusions - Engaging chapter summaries with:
    • "What You've Learned" covering programming, statistics, economics, and methodology
    • "Looking Ahead" connecting to future chapters
  6. Standardized References - Consistent citations to Cameron (2022) with data URLs
  7. Professional Formatting - Clean titles and consistent structure throughout

Quality Standards

  • 100% coverage: All 17 chapters enhanced
  • ~105 context sections across all chapters (avg 6.2 per chapter)
  • ~51 concept boxes across all chapters (avg 3.0 per chapter)
  • Consistent structure: Same pedagogical pattern throughout
  • Publication ready: Professional formatting suitable for textbook use

πŸ“Š Case Studies: Real Research Applications

Each chapter includes hands-on case studies that bridge textbook theory with real economic research. Students apply econometric tools to authentic datasets with progressive tasks (guided β†’ semi-guided β†’ independent).

Featured Datasets

1. Economic Convergence Clubs (Mendez, 2020)

  • 108 countries, 1990–2014, panel data on GDP, productivity, capital, human capital, TFP
  • Used in CH01, CH02, CH04, CH07–CH12, CH14–CH17

2. Can Satellites See Development? (DS4Bolivia)

  • 339 Bolivian municipalities, satellite nighttime lights + 64 embedding features, SDG indices
  • Used in CH01, CH02, CH04, CH05, CH07, CH10–CH12, CH14–CH17

All data loads directly from GitHub (no downloads required). See individual chapter notebooks for case study details.


πŸ“– Online HTML Book (Quarto)

All 18 chapters are published as an interactive online book using Quarto.

  • Status: βœ… Complete - 18 chapters in 4 parts
  • URL: quarcs-lab.github.io/metricsai/book/_book/
  • Location: book/ directory
  • Features:
    • Searchable full-text across all chapters
    • Google Translate integration on every page
    • Responsive design for desktop and mobile
    • Four-part structure: Statistical Foundations, Bivariate Regression, Multiple Regression, Advanced Topics

The HTML book complements the interactive notebooks, ideal for:

  • Reading without needing Google Colab
  • Searching across all chapters
  • Quick reference and navigation
  • Students who prefer a traditional book layout

πŸ”„ Jupytext: Dual-Format Notebooks

All notebooks are maintained in two synchronized formats using Jupytext:

  • .ipynb β€” Standard Jupyter notebook (runs in Colab, contains outputs)
  • .md β€” MyST Markdown source (text-based, ideal for version control)

Edit either format β€” Jupytext synchronizes them automatically. Configuration is embedded in each notebook's metadata (no separate config files needed).

Benefits

  • Better diffs β€” Text-based .md files produce clean, readable git diffs
  • Easy editing β€” Edit notebooks in any text editor or IDE
  • Reduced conflicts β€” Merge conflicts are simpler to resolve in plain text
  • Full compatibility β€” .ipynb files work in Colab/Jupyter without Jupytext installed

Quick Reference

# Sync a single notebook after editing the .md file
jupytext --sync notebooks_colab/ch05_*.md

# Sync all notebooks
jupytext --sync notebooks_colab/*.ipynb

πŸ“„ Automated PDF Generation

Individual Jupyter notebooks can be automatically exported to professional-quality PDF files using Playwright. The system preserves all content including markdown text, code, mathematical equations, tables, and figures with precise formatting control.

Quick Start

Generate a single chapter PDF:

# Step 1: Convert notebook to HTML
cd notebooks_colab && jupyter nbconvert --to html ch05_*.ipynb && cd ..

# Step 2: Inject CSS and generate PDF
python3 scripts/inject_print_css.py notebooks_colab/ch05_*.html notebooks_colab/ch05_*_printable.html && \
python3 scripts/generate_pdf_playwright.py ch05

# Step 3: View result
open notebooks_colab/ch05_*.pdf

Generate all chapters at once:

# Convert all notebooks to HTML
cd notebooks_colab && for nb in ch*.ipynb; do jupyter nbconvert --to html "$nb"; done && cd ..

# Generate all PDFs with Playwright
python3 scripts/generate_pdf_playwright.py --all

# Verify output
ls -lh notebooks_colab/*.pdf

Current Status

All 18 chapter PDFs generated (as of 2026-02-08):

  • βœ… ch00–ch17 complete (0.9–2.0 MB each, 15–72 pages each)
  • βœ… Compiled book: notebooks_colab/metricsAI_complete_book.pdf (62.3 MB, 900 pages)

Professional Formatting Features

  • Justified text alignment - Professional book-style typography
  • Full-width visual summaries - Chapter opening images span full page width (7 inches)
  • Optimized regression tables - 7.5pt font size prevents text overflow and wrapping
  • Uniform margins - 0.75 inches on all sides
  • No headers/footers - Clean pages with maximum content space
  • Clickable hyperlinks - URLs remain interactive without printing as text
  • Brand-consistent design - Color hierarchy using project palette (Cyan, Purple, Pink, Navy)
  • Modern typography - Inter font for body text (11pt), JetBrains Mono for code (9pt input, 7.5pt output)
  • Professional appearance - Publication-quality, print-ready output

System Components

  1. scripts/generate_pdf_playwright.py (248 lines) - Primary PDF generator using Playwright

    • Precise control over margins, fonts, and page layout
    • Letter format (8.5" Γ— 11") portrait orientation
    • Handles font loading and CSS rendering
  2. scripts/inject_print_css.py - CSS injection tool

    • Injects custom styles into HTML files
    • Creates "_printable.html" versions
  3. scripts/notebook_pdf_styles.css (426 lines) - Master stylesheet

    • All typography, colors, spacing, and layout rules
    • Justified text with @media print rules
    • Optimized font sizes for output blocks

Prerequisites

Installation:

# Install Playwright
pip install playwright

# Install Playwright browsers
playwright install chromium

Complete Documentation

For comprehensive workflow documentation, troubleshooting, and technical details, see:

log/20260129_PDF_GENERATION_WORKFLOW.md

This 600+ line document includes:

  • Step-by-step workflow for single and batch processing
  • Complete formatting specifications
  • Troubleshooting guide with 7 common issues
  • Technical details with exact CSS line numbers
  • File structure and dependencies
  • Future update instructions

Why Playwright?

The automated Playwright approach provides:

  • Precise control - Exact margins, no unwanted headers/footers
  • Consistent output - Reproducible results across all chapters
  • Better CSS rendering - Full support for modern CSS features
  • Font loading - Proper Google Fonts integration
  • Automation - Process all 18 chapters with one command
  • Production ready - Professional formatting suitable for distribution

Use Cases

  • Student distribution - Share notebooks without requiring Python/Colab
  • Print for offline study - Professional book-style formatting on paper
  • Course materials - Include in syllabus or reading packs
  • Archival - Preserve executed output with all figures
  • Professional reports - Publication-quality documentation

πŸ‘₯ Authors and Credits

Carlos Mendez - Python implementation and educational notebook development

A. Colin Cameron - Original textbook, data, Stata/R code, slides.

This project builds on Professor Cameron's excellent textbook and openly shared code examples and data, translating them into cloud-ready Python implementations for modern econometrics education.

About

metricsAI: An Introduction to Econometrics with Python and AI in the Cloud

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •