<commit_before>{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "YTW94aX0fWCQ"
      },
      "source": [
        "# LightweightMMM Models.\n",
        "\n",
        "The LightweightMMM can either be run using data aggregated at the national level (standard approach) or using data aggregated at a geo level (sub-national hierarchical approach). These models are documented below.\n",
        "\n",
        "## National level (standard approach)\n",
        "\n",
        "All the parameters in our Bayesian model have priors which have been set based on simulated studies that produce stable results. We also set out our three different approaches to saturation and media lagging effects: carryover (with exponent), adstock (with exponent) and hill adstock. Please see <NAME>. et al., (2017) for more details on these models and choice of priors.\n",
        "\n",
        " $$kpi_{t} = \\alpha + trend_{t} + seasonality_{t} + media\\ channels_{t} + other\\ factors_{t} $$\n",
        "\n",
        "*Intercept*\u003cbr\u003e\n",
        "- $\\alpha \\sim HalfNormal(2)$\n",
        "\n",
        "*Trend*\u003cbr\u003e\n",
        "- $trend_{t} = \\mu t^{\\kappa}$\u003cbr\u003e\n",
        "- $\\mu \\sim Normal(0,1)$\u003cbr\u003e\n",
        "- $\\kappa \\sim Uniform(0.5,1.5)$\u003cbr\u003e\n",
        "- Where $t$ is a linear trend input\n",
        "\n",
        "*Seasonality (for models using* **weekly observations**)\u003cbr\u003e\n",
        "- $seasonality_{t} = \\displaystyle\\sum_{d=1}^{2} (\\gamma_{1,d} cos(\\frac{2 \\pi d}{52}) + \\gamma_{2,d} sin(\\frac{2 \\pi d}{52}))$\u003cbr\u003e\n",
        "- $\\gamma_{1,d}, \\gamma_{2,d} \\sim Normal(0,1)$\u003cbr\u003e\n",
        "\n",
        "*Seasonality (for models using* **daily observations**)\u003cbr\u003e\n",
        "- $seasonality_{t} = \\displaystyle\\sum_{d=1}^{2} (\\gamma_{1,d} cos(\\frac{2 \\pi d}{365}) + \\gamma_{2,d} sin(\\frac{2 \\pi d}{365})) + \\displaystyle\\sum_{i=1}^{7} \\delta_{i}$\u003cbr\u003e\n",
        "- $\\gamma_{1,d}, \\gamma_{2,d} \\sim Normal(0,1)$\u003cbr\u003e\n",
        "- $\\delta_{i} \\sim Normal(0,0.5)$\u003cbr\u003e\n",
        "\n",
        "*Other factors*\u003cbr\u003e\n",
        "- $other\\ factors_{t} = \\displaystyle\\sum_{i=1}^{N} \\lambda_{i}Z_{i}$\u003cbr\u003e\n",
        "- $\\lambda_{i}  \\sim  Normal(0,1)$\u003cbr\u003e\n",
        "- Where $Z_{i}$ are other factors and $N$ is the number of other factors.\n",
        "\n",
        "*Media Effect*\u003cbr\u003e\n",
        "- $\\beta_{m} \\sim HalfNormal(v_{m})$\u003cbr\u003e\n",
        "- Where $v_{m}$ is a scalar equal to the sum of the total cost of media channel $m$.\n",
        "\n",
        "*Media Channels (for the* **carryover** *model)*\u003cbr\u003e\n",
        "- $media\\ channels_{t} = x_{t,m}^{*\\rho_{m}}$\u003cbr\u003e\n",
        "- $x_{t,m}^{*} = \\frac{\\displaystyle\\sum_{l=0}^{L} \\tau_{m}^{(l-\\theta_{m})^2}x_{t-l,m}}{\\displaystyle\\sum_{l=0}^{L}\\tau_{m}^{(l-\\theta_{m})^2}}$  where $L=12$\u003cbr\u003e\n",
        "- $\\tau_{m} \\sim Beta(1,1)$\u003cbr\u003e\n",
        "- $\\theta_{m} \\sim HalfNormal(2)$\u003cbr\u003e\n",
        "- $\\rho_{m} \\sim Beta(9,1)$\n",
        "- Where $x_{t,m}$ is the media spend or impressions in week $t$ from media channel $m$\u003cbr\u003e\n",
        "\n",
        "*Media Channels (for the* **adstock** *model)*\u003cbr\u003e\n",
        "- $media\\ channels_{t} = x_{t,m,s}^{*\\rho_{m}}$\u003cbr\u003e\n",
        "- $x_{t,m,s}^{*} = \\frac{x_{t,m}^{*}}{1/(1-\\lambda_{m})}$\u003cbr\u003e\n",<commit_msg>update notation in documentation, per issue #102<commit_after>{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "YTW94aX0fWCQ"
      },
      "source": [
        "# LightweightMMM Models.\n",
        "\n",
        "The LightweightMMM can either be run using data aggregated at the national level (standard approach) or using data aggregated at a geo level (sub-national hierarchical approach). These models are documented below.\n",
        "\n",
        "## National level (standard approach)\n",
        "\n",
        "All the parameters in our Bayesian model have priors which have been set based on simulated studies that produce stable results. We also set out our three different approaches to saturation and media lagging effects: carryover (with exponent), adstock (with exponent) and hill adstock. Please see Jin, Y. et al., (2017) for more details on these models and choice of priors.\n",
        "\n",
        " $$kpi_{t} = \\alpha + trend_{t} + seasonality_{t} + media\\ channels_{t} + other\\ factors_{t} $$\n",
        "\n",
        "*Intercept*\u003cbr\u003e\n",
        "- $\\alpha \\sim HalfNormal(2)$\n",
        "\n",
        "*Trend*\u003cbr\u003e\n",
        "- $trend_{t} = \\mu t^{\\kappa}$\u003cbr\u003e\n",
        "- $\\mu \\sim Normal(0,1)$\u003cbr\u003e\n",
        "- $\\kappa \\sim Uniform(0.5,1.5)$\u003cbr\u003e\n",
        "- Where $t$ is a linear trend input\n",
        "\n",
        "*Seasonality (for models using* **weekly observations**)\u003cbr\u003e\n",
        "- $seasonality_{t} = \\displaystyle\\sum_{d=1}^{2} (\\gamma_{1,d} cos(\\frac{2 \\pi dt}{52}) + \\gamma_{2,d} sin(\\frac{2 \\pi dt}{52}))$\u003cbr\u003e\n",
        "- $\\gamma_{1,d}, \\gamma_{2,d} \\sim Normal(0,1)$\u003cbr\u003e\n",
        "\n",
        "*Seasonality (for models using* **daily observations**)\u003cbr\u003e\n",
        "- $seasonality_{t} = \\displaystyle\\sum_{d=1}^{2} (\\gamma_{1,d} cos(\\frac{2 \\pi dt}{365}) + \\gamma_{2,d} sin(\\frac{2 \\pi dt}{365})) + \\delta_{t \\bmod 7}$\u003cbr\u003e\n",
        "- $\\gamma_{1,d}, \\gamma_{2,d} \\sim Normal(0,1)$\u003cbr\u003e\n",
        "- $\\delta_{i} \\sim Normal(0,0.5)$\u003cbr\u003e\n",
        "\n",
        "*Other factors*\u003cbr\u003e\n",
        "- $other\\ factors_{t} = \\displaystyle\\sum_{i=1}^{N} \\lambda_{i}Z_{it}$\u003cbr\u003e\n",
        "- $\\lambda_{i}  \\sim  Normal(0,1)$\u003cbr\u003e\n",
        "- Where $Z_{i}$ are other factors and $N$ is the number of other factors.\n",
        "\n",
        "*Media Effect*\u003cbr\u003e\n",
        "- $\\beta_{m} \\sim HalfNormal(v_{m})$\u003cbr\u003e\n",
        "- Where $v_{m}$ is a scalar equal to the sum of the total cost of media channel $m$.\n",
        "\n",
        "*Media Channels (for the* **carryover** *model)*\u003cbr\u003e\n",
        "- $media\\ channels_{t} = x_{t,m}^{*\\rho_{m}}$\u003cbr\u003e\n",
        "- $x_{t,m}^{*} = \\frac{\\displaystyle\\sum_{l=0}^{L} \\tau_{m}^{(l-\\theta_{m})^2}x_{t-l,m}}{\\displaystyle\\sum_{l=0}^{L}\\tau_{m}^{(l-\\theta_{m})^2}}$  where $L=12$\u003cbr\u003e\n",
        "- $\\tau_{m} \\sim Beta(1,1)$\u003cbr\u003e\n",
        "- $\\theta_{m} \\sim HalfNormal(2)$\u003cbr\u003e\n",
        "- $\\rho_{m} \\sim Beta(9,1)$\n",
        "- Where $x_{t,m}$ is the media spend or impressions in week $t$ from media channel $m$\u003cbr\u003e\n",
        "\n",
        "*Media Channels (for the* **adstock** *model)*\u003cbr\u003e\n",
        "- $media\\ channels_{t} = x_{t,m,s}^{*\\rho_{m}}$\u003cbr\u003e\n",
        "- $x_{t,m,s}^{*} = \\frac{x_{t,m}^{*}}{1/(1-\\lambda_{m})}$\u003cbr\u003e\n",
{'fraction_non_alphanumeric': 0.231280276816609, 'fraction_numerical': 0.06145328719723184, 'mean_word_length': 2.4891356832448093, 'pattern_counts': {'":': 10, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '302595', 'n_tokens_mistral': 3000, 'n_tokens_neox': 2704, 'n_words': 577}