{
  "nbformat": 4,
  "nbformat_minor": 5,
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "pygments_lexer": "ipython3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# 10 Forecast\n",
        "\n",
        "On holdout months, does the pre-2020 mean for that calendar month beat a forecast of a zero monthly log return?\n",
        "\n",
        "Holdout starts 2020-01-01. Verdict: held.\n",
        "\n",
        "This study reads stored series. It does not add a derived column."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {},
      "source": [
        "import json\n",
        "from pathlib import Path\n",
        "studies = json.loads(Path('data/studies.json').read_text())\n",
        "study = next(item for item in studies['studies'] if item['slug'] == 'forecast')\n",
        "print(study['verdict'])\n",
        "print(study['verdict_line'])\n",
        "print(study['table']['caption'])\n",
        "for row in study['table']['rows']:\n",
        "    print(' | '.join(row))\n"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "held\n",
            "Holdout months: 81. Mean absolute error of the train calendar-month mean is 10.162%. Mean absolute error of a flat zero forecast is 10.365%. The difference is 0.204%. The calendar mean is lower error, which was the bar.\n",
            "Holdout monthly RWTC log return, mean absolute error\n",
            "Train mean for that calendar month | 81 | 10.162%\n",
            "Flat zero | 81 | 10.365%\n",
            "TimesFM median, one month ahead | 81 | 10.535%\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Method\n",
        "\n",
        "Mean absolute error on holdout months decides it. The seasonal forecast has to be strictly lower error than zero.\n",
        "\n",
        "## Result\n",
        "\n",
        "Holdout months: 81. Mean absolute error of the train calendar-month mean is 10.162%. Mean absolute error of a flat zero forecast is 10.365%. The difference is 0.204%. The calendar mean is lower error, which was the bar."
      ]
    }
  ]
}
