{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Chapter 32: Regularization and High-Dimensional Economic Models\n",
        "**Economic question:** How do we build stable predictions when the number of candidate predictors becomes large?\n",
        "\nRegularization accepts some bias in exchange for lower variance and more stable out-of-sample prediction.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import numpy as np\n",
        "from sklearn.linear_model import RidgeCV, LassoCV\n",
        "rng=np.random.default_rng(32); X=rng.normal(size=(500,30)); b=np.zeros(30); b[:5]=[2,-1.5,1,.5,.3]; y=X@b+rng.normal(size=500)\n",
        "print('ridge alpha',RidgeCV(alphas=np.logspace(-3,3,40)).fit(X,y).alpha_)\n",
        "print('lasso alpha',LassoCV(cv=5,random_state=1).fit(X,y).alpha_)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Interpretation checklist\n",
        "- State the unit of observation and units of every variable.\n",
        "- Separate association, prediction, and causation.\n",
        "- Report magnitude and uncertainty.\n",
        "- Identify the most important threat to validity.\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.13"
    },
    "ceteris_lab": {
      "course_slug": "fundamentals-python-econometrics",
      "course_title": "Fundamentals of Python for Financial Econometrics",
      "chapter": 32,
      "source_origin": "supplied"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}
