help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
statsmodels-statistical
/
notebooks
RSK World
statsmodels-statistical
Statistical Modeling with Statsmodels
notebooks
  • 01_linear_regression.ipynb7.6 KB
  • 02_time_series.ipynb5 KB
  • 03_hypothesis_testing.ipynb4.3 KB
  • 04_econometric_modeling.ipynb4.9 KB
04_econometric_modeling.ipynb
notebooks/04_econometric_modeling.ipynb
Raw Download
Find: Go to:
{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Econometric Modeling with Statsmodels\n",
        "\n",
        "<!--\n",
        "Author: RSK World\n",
        "Website: https://rskworld.in\n",
        "Email: help@rskworld.in\n",
        "Phone: +91 93305 39277\n",
        "Description: Econometric modeling including VAR, cointegration, and impulse response functions\n",
        "-->\n",
        "\n",
        "This notebook demonstrates econometric modeling techniques.\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Load Econometric Data\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Try to load econometric data from file\n",
        "import os\n",
        "econ_data_path = os.path.join('..', 'data', 'econometric_data.csv')\n",
        "if os.path.exists(econ_data_path):\n",
        "    econ_df = pd.read_csv(econ_data_path, parse_dates=['date'], index_col='date')\n",
        "    print(\"Loaded Econometric Data:\")\n",
        "    print(econ_df.head())\n",
        "    print(f\"\\nData Shape: {econ_df.shape}\")\n",
        "    data = econ_df[['GDP', 'Consumption', 'Investment']]\n",
        "else:\n",
        "    print(\"Data file not found. Using generated data.\")\n",
        "    # Generate sample data\n",
        "    np.random.seed(42)\n",
        "    dates = pd.date_range('2020-01-01', periods=200, freq='D')\n",
        "    y1 = np.cumsum(np.random.randn(200) * 0.1) + 100\n",
        "    y2 = y1 * 0.85 + np.random.randn(200) * 0.3\n",
        "    data = pd.DataFrame({'GDP': y1, 'Consumption': y2}, index=dates)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Visualize Data\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Visualize econometric data\n",
        "from visualization_utils import StatisticalVisualizations\n",
        "\n",
        "viz = StatisticalVisualizations()\n",
        "viz.plot_multiple_time_series({\n",
        "    'GDP': data['GDP'] if 'GDP' in data.columns else data.iloc[:, 0],\n",
        "    'Consumption': data['Consumption'] if 'Consumption' in data.columns else data.iloc[:, 1]\n",
        "}, title=\"Econometric Time Series\")\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Panel Data Analysis\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Panel data analysis\n",
        "from panel_data_analysis import PanelDataAnalysis\n",
        "\n",
        "# Try to load panel data\n",
        "panel_data_path = os.path.join('..', 'data', 'panel_data.csv')\n",
        "if os.path.exists(panel_data_path):\n",
        "    panel_df = pd.read_csv(panel_data_path)\n",
        "    print(\"Loaded Panel Data:\")\n",
        "    print(panel_df.head())\n",
        "    \n",
        "    panel = PanelDataAnalysis()\n",
        "    panel.prepare_panel_data(panel_df, 'entity', 'time', ['X1', 'X2', 'y'])\n",
        "    \n",
        "    # Fixed effects\n",
        "    print(\"\\n\" + \"=\" * 70)\n",
        "    print(\"Fixed Effects Regression:\")\n",
        "    print(\"=\" * 70)\n",
        "    fe_model = panel.fixed_effects_regression('y', ['X1', 'X2'])\n",
        "    \n",
        "    # Random effects\n",
        "    print(\"\\n\" + \"=\" * 70)\n",
        "    print(\"Random Effects Regression:\")\n",
        "    print(\"=\" * 70)\n",
        "    re_model = panel.random_effects_regression('y', ['X1', 'X2'])\n",
        "else:\n",
        "    print(\"Panel data file not found.\")\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Import libraries\n",
        "import numpy as np\n",
        "import pandas as pd\n",
        "import sys\n",
        "import os\n",
        "\n",
        "sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))\n",
        "from econometric_modeling import EconometricModel\n",
        "\n",
        "# Generate sample data\n",
        "np.random.seed(42)\n",
        "dates = pd.date_range('2020-01-01', periods=200, freq='D')\n",
        "y1 = np.cumsum(np.random.randn(200) * 0.1) + 100\n",
        "y2 = y1 * 0.85 + np.random.randn(200) * 0.3\n",
        "data = pd.DataFrame({'GDP': y1, 'Consumption': y2}, index=dates)\n",
        "\n",
        "econ_model = EconometricModel()\n",
        "econ_model.fit_var(data, maxlags=5)\n",
        "econ_model.var_summary()\n"
      ]
    }
  ],
  "metadata": {
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 2
}
152 lines•4.9 KB
json

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer