{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "x71JNXQqeHth",
        "outputId": "dc1c3748-6e86-4f23-bb8a-4d3708bfcd2b"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Note: you may need to restart the kernel to use updated packages.\n"
          ]
        }
      ],
      "source": [
        "%pip install openai --upgrade -q"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "metadata": {
        "id": "pckHOx_Wd9oz"
      },
      "outputs": [],
      "source": [
        "import getpass\n",
        "from openai import OpenAI\n",
        "\n",
        "secret_key = getpass.getpass(\"Enter your OpenAI secret key: \")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 5,
      "metadata": {},
      "outputs": [],
      "source": [
        "client = OpenAI(api_key=secret_key)\n",
        "MODEL=\"gpt-4.1-mini\""
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 18,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "fgYgIyNkc0d0",
        "outputId": "25f84518-7e72-479b-cde6-09379fd96c74"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "---\n",
            "Hey! Yes, I'm ready. How can I help you today?\n"
          ]
        }
      ],
      "source": [
        "# return response from openai:\n",
        "def submit_prompt(prompt, temp=0.7, tokens=256):\n",
        "    response = client.responses.create(\n",
        "        model=MODEL,\n",
        "        input=[{\n",
        "            \"role\": \"user\",\n",
        "            \"content\": [{\n",
        "                \"type\": \"input_text\",\n",
        "                \"text\": prompt\n",
        "            }]\n",
        "        }],\n",
        "        text={\n",
        "            \"format\": {\n",
        "                \"type\": \"text\"\n",
        "            }\n",
        "        },\n",
        "        temperature=temp,\n",
        "        max_output_tokens=tokens,\n",
        "        store=False\n",
        "    )\n",
        "\n",
        "    # Parse out the response\n",
        "    response_text = response.output[0].content[0].text\n",
        "    return response_text\n",
        "\n",
        "print(\"---\")\n",
        "print(submit_prompt(\"Hey GPT are you ready?\"))"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 23,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "Mh2J3q5ieSOh",
        "outputId": "56a319a3-93ac-4e0f-e3c4-321d943f940b"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Summarize this for an eight-grade student as a tweet of 280 characters (no hashtags, no emojis, no links):\n",
            "*Text goes here*\n"
          ]
        }
      ],
      "source": [
        "# summary\n",
        "# https://contently.com/2021/01/28/this-surprising-reading-level-analysis-will-change-the-way-you-write/\n",
        "summary_prompt = \"Summarize this for an eight-grade student as a tweet of 280 characters (no hashtags, no emojis, no links):\\n{text}\"\n",
        "\n",
        "text = \"*Text goes here*\"\n",
        "print(summary_prompt.format(text=text))"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 20,
      "metadata": {
        "id": "OfIbZRj9ZYDy"
      },
      "outputs": [],
      "source": [
        "# articles\n",
        "# https://getrecast.com/modern-media-mix-modeling/\n",
        "# https://www.saxifrage.xyz/post/econometrics-gsheets\n",
        "# https://blog.hurree.co/blog/marketing-mix-modeling\n",
        "# https://www.thinkwithgoogle.com/marketing-strategies/data-and-measurement/art-of-marketing-mix-models/\n",
        "# https://digiday.com/marketing/wtf-is-marketing-mix-modeling/\n",
        "# https://towardsdatascience.com/market-mix-modeling-mmm-101-3d094df976f9\n",
        "# https://en.wikipedia.org/wiki/Marketing_mix_modeling\n",
        "\n",
        "publishers = [\"Recast\", \"Saxifrage\", \"Hurree\", \"Google\", \"Digiday\", \"Aryma Labs\", \"Wikipedia\"]\n",
        "\n",
        "texts = [\n",
        "\"\"\"\n",
        "Modern Media Mix Modeling\n",
        "\n",
        "With the rise of e-commerce, online advertising, and the ability for companies to perform fine-grained digital attribution at the customer level, media-mix modeling has fallen in popularity and many marketers of the newest generation are not familiar with this very important tool for optimizing a marketing program.\n",
        "\n",
        "In this blog post I’ll review the history of media-mix modeling, discuss why customer level attribution based on click-tracking is insufficient, review the challenges with media mix modeling in the context of “programmatic” channels, and finally, I’ll discuss how Recast addresses these problems. Let’s dive in!\n",
        "\n",
        "A brief history of MMM\n",
        "The problem to solve\n",
        "Imagine that you run the marketing department for a CPG brand in the 1980’s — your products are distributed through third-party retailers like Sears, grocery store chains, or a growing chain called “Walmart”. Your primary advertising channels are television, radio, direct mail, and print advertising in newspapers). Critically, outside of the use of coupons (which have their obvious downsides and limitations), there is no good way to tell which people saw your advertisements and which of those went on to make a purchase.\n",
        "\n",
        "“Half the money I spend on advertising is wasted; the trouble is I don’t know which half.” — John Wanamaker, retail pioneer\n",
        "\n",
        "Enter the econometricians\n",
        "In the late 80s and early 90s, econometricians began developing techniques to estimate the impact of these different advertising channels on sales. By using sophisticated regression techniques, they were able to link how changs in spend in the “media mix” (say, one week where spend in television increased and spend in radio decreased) to changes in the number of total sales. While some of the math under the hood can get tricky, the concept is straightforward: the models take advantage of “natural experiments” in the levels of media spend in order to understand how the different channels impact downstream sales.\n",
        "\n",
        "This type of modeling became a critical tool in the marketing departments of large consumer-facing brands, and a number of companies and consulting firms stepped up to further develop this technology and provide the models as a service to brands. To this day, most large brands (especially those that are primarily distributed through brick-and-mortar stores) either do this type of modeling in-house or contract with one of a few large providers in order to drive their planning and budgeting process.\n",
        "\n",
        "Online advertising and attribution\n",
        "With the rise of the internet and, especially, direct-to-consumer internet brands, the story changed. Brands like Warby Parker and Casper that started in the early 2010’s sold directly to customers online and were driven primarily by online advertising. Critically, when advertising in channels like Facebook and Google search, you can know exactly which customers saw your ads and whether they converted or not. So rather than having to use a complicated statistical model to estimate the impact of your advertising spend, you can see the “conversion rate” and ROI right at the top of the dashboard of any digital advertising platform.\n",
        "\n",
        "Problem solved, right?\n",
        "Unfortunately, digital advertising tracking turned out not to be the panacea that some had hoped. While we don’t have space for a deep-dive into the nitty-gritty details, we’ll cover most of the generally-accepted flaws with click-tracking-based attribution methods.\n",
        "\n",
        "Last-click attribution over-credits bottom-of-funnel channels\n",
        "Most companies that do click-tracking based attribution use what’s called “last-click” attribution. That is, when doing their ROI calculation, they attribute the sale to the last advertisement the customer clicked on before converting. While in general this is a great way to get started measuring advertising efficacy, very obviously this methodology will over-credit channels that are closer to the bottom of the advertising funnel (like paid search) and will under-credit more awareness-building top-of-funnel channels (like video advertising on YouTube).\n",
        "\n",
        "How to integrate offline and online channels?\n",
        "Most big brands today, even direct-to-consumer brands that only sell online, are advertising in a mix of online and offline channels: TV, facebook, radio, google search, podcast, banner ads, direct mail, etc. This mix of channels exacerbates the problem with trying to use a pure click-based attribution model: you try to “track” customers coming from offline channels using coupon codes or surveys and then you use a rule-of-thumb smudge to try to come up with an ROI estimate.\n",
        "\n",
        "The more channels a company is operating in, the more these types of guesswork analyses can lead the marketing team astray and lead to millions of dollars wasted on channels that don’t actually drive incremental sales.\n",
        "\n",
        "Correlation vs. Causation\n",
        "This leads us to one of the subtler — but no less important — points. Even if a marketing team were to overcome all the measurement challenges across different types of channels that target different stages of the consumer journey, they would still be left with a thorny problem: attribution models don’t, even in principle, tell the marketer where they should allocate additional spend to drive incremental sales.\n",
        "\n",
        "Why is this? Attribution models don’t correct for something econometricians call endogeneity, and you might think of as feedback loops. We think of increased spend on marketing as causing increased sales (and that’s the effect we want to isolate), but we have to remember that increased sales can also cause increased spend on marketing, and other factors can cause increases in both at the same time. For example, someone that was already going to buy your product might click on a Google ad because it’s the simplest way to get to your site, or a marketer might increase spend in anticipation of a seasonal bump that was going to increase your sales anyway.\n",
        "\n",
        "Without correcting for endogeneity, attribution numbers are correlations, not causal effects, and should bear a large flashing warning of “past performance does not guarantee future results”.\n",
        "\n",
        "The future is omni-channel\n",
        "Most businesses have come to recognize that the future of retail is omni-channel. Challenger brands like Casper, Warby Parker, and Harry’s have all moved into physical retail by opening their own brick-and-mortar locations or distributing through retailers like Walmart and Target, and brands like Nike have invested heavily in building a powerful e-commerce engine to complement their brick-and-mortar presence. In the omni-channel world, using a purely click-based attribution model begins to break down very quickly as it is not clear at all how to link impressions on Facebook to in-store conversions at Walmart.\n",
        "\n",
        "This blend of omni-channel advertising and omni-channel purchase options has, justifiably, left modern marketers in a real bind when it comes to deciding how to improve the overall performance of their marketing program.\n",
        "\n",
        "Can Media Mix Modeling can Help?\n",
        "Unfortunately, things aren’t as simple as they were in the olden days, and the statistical models developed in the past are no longer valid in a world where large amounts of money are spent on programmatic advertising.\n",
        "\n",
        "The programmatic puzzle\n",
        "If you’re not familiar with the term, “programmatic” channels are advertising channels like Facebook or Google search where advertising spend happens dynamically in response to user behavior: if customers click on your ad a lot, Google and Facebook will both charge you and serve your ad to more customers.\n",
        "\n",
        "It’s the last part that causes a problem for traditional media mix models — in a programmatic channel, the amount of spend is chosen by the platform, not by the advertiser. Additionally, the platform could react to outside causes — if an excellent TV campaign builds a lot of trust in your brand, Facebook might register increased engagement with your ads and subsequently ramp up spend to show your ads to more people. A traditional Media Mix Model will be biased toward allocating credit to Facebook for those conversions, even though it was the TV spend that really did the heavy lifting, and one might imagine that many of those people might have purchased anyway whether they saw the Facebook ad or not.\n",
        "\n",
        "Because with programmatic advertising purchasing behavior can drive advertising spend in addition to advertising spend driving purchasing behavior, the assumptions in traditional Media Mix Modeling are broken, and the estimates are biased.\n",
        "\n",
        "So, the whole situation is hosed and no one knows anything?\n",
        "\n",
        "Recast’s Incrementality Model\n",
        "We’ve developed a proprietary solution to solving this problem and have built Recast as a modern alternative to traditional media mix modeling. Recast was built from the ground up to use a statistical model to estimate the true incrementality of marketing spend in both programmatic and non-programmatic channels.\n",
        "\n",
        "Recast is the only media mix model designed to operate in a true omni-channel world — to learn more, reach out at info@getrecast.com or get started here.\n",
        "\"\"\",\n",
        "\"\"\"\n",
        "Econometrics in GSheets\n",
        "November 26, 2021\n",
        "\n",
        "Michael Taylor\n",
        "Growth Economics\n",
        "You may have heard the term Econometrics or \"Marketing Mix Modeling\" (which is Econometrics applied to Marketing), but most don't know how it works. The World's largest advertisers like Procter & Gamble, Unilever and Coca-Cola use it to measure marketing ROI — for example calculating how many incremental sales a Superbowl ad drove.\n",
        "\n",
        "This is an entry level post, so if you have heard of MMM and want to dive deeper to learn more, we have a lot of intermediate to advanced marketing mix modeling courses at vexpower.com.\n",
        "\n",
        "These methods are performed on behalf of large brands by experienced specialists to make life or death decisions on where to allocate multi-million dollar marketing budgets. When done well, Econometrics can answer valuable questions:\n",
        "\n",
        "Is Facebook really responsible for as many sales as they’re reporting?\n",
        "How do I calculate ROI when I invest in less measurable channels like TV?\n",
        "Did my agency actually drive this spike in sales, or was it some other factor?\n",
        "How much more do I sell when I lower my prices, or run a promotion?\n",
        "What would happen to revenue if I increased my marketing budget?\n",
        "These are core strategic questions that every marketing leader must answer, yet many resort to guesswork when making these decisions. There’s a lack of awareness amongst marketers around what Econometrics is, what it can do, and how it works.\n",
        "\n",
        "Given the value of these techniques, and the politics that come with making large-scale budget decisions, most Econometricians are hesitant to share their methods. Thankfully, the core techniques can be easily replicated in Google Sheets, which is what I’ve done here:\n",
        "\n",
        "Econometric Model for Pie Sales\n",
        "There’s no complex math, and you don’t need a degree in statistics to understand it. This example uses fake data for a fictional company selling pies, but it’s enough to showcase the techniques involved. You can use this template to build your own model, or just follow along to become more informed before working with a professional (get in touch if you need help). If you're familiar with Econometrics and want to learn how to do this in Python, see Econometrics in Python.\n",
        "\n",
        "With the rise of digital advertising and technologies like micro-targeting, methods like Market Mix Modelling began to look old-fashioned vs tracking each user directly to purchase. However with 30% adoption of ad blockers, the roll out of consumer privacy legislation like GDPR and CCPA, and moves against 3rd-party cookies or unique identifiers, expect a shift back to privacy-friendly marketing attribution methods like Econometrics.\n",
        "\n",
        "What can Econometric Modelling do?\n",
        "Econometrics is the practice of applying statistical techniques to economic data to explain the underlying relationships in the data. The common application we’re concerning ourselves with is called Marketing Mix Modelling, which attempts to predict sales based on factors like how much you spent on advertising, what price you set for your products or if it was a sunny day.\n",
        "\n",
        "These factors are input as variables in a multivariate linear regression analysis, which outputs coefficients you can plug into an equation. This is important not just because it’s useful to be able to predict sales, but because knowing how predictive each variable is, tells you the contribution of that factor to revenue. Meaning you can calculate how much revenue you made from marketing, without needing to track your user’s conversion journey’s directly.\n",
        "\n",
        "What makes sales go up and down?\n",
        "Taking our fictional pie company (data from Jalayer Academy), we can chart our sales over time and see the line moving up and down without explanation. If you go ahead and chart your sales in the same fashion, you’ll see movements up and down unique to your company.\n",
        "\n",
        "\n",
        "The main question we’re trying to answer is ‘what makes sales go up and down’. If we know that, we can strip out external factors (‘do sales go up or down when it’s a holiday?’) and determine what credit internal factors deserve (‘how much revenue did my advertising generate?’).\n",
        "\n",
        "Match spikes and dips to internal and external factors\n",
        "If we take just one variable like the average price at which we sold our pies, we can see how much that factor explains the changes in sales. We intuitively expect that a lower price will sell more pies, but our analysis will tell us how much more for each dollar change in price.\n",
        "\n",
        "\n",
        "If we do a simple scatter plot chart and add a trendline, we can see that Price on its own explains only about 19% of the variance in the sales data. There does visually seem to be a downwards trend where the higher the price the lower the sales, which makes sense.\n",
        "\n",
        "\n",
        "Plotting out our predictions based solely on price, we can tell we’re not seeing the full picture here – our forecast is consistently off by a large enough amount to render our model useless in making predictions on sales. This is reassuring, because if price explained all of the variance, it would be the same as saying our marketing budget had no impact!\n",
        "\n",
        "Introduce more variables to better fit the line\n",
        "The aim of the game is to dig through our data to find the right mix of variables to introduce in our model, so as to explain away more of the movement in sales. As marketers we’re doing this analysis to find out what impact our marketing had on revenue, so let’s add that as a variable.\n",
        "\n",
        "\n",
        "You don’t need a background in statistics to see what’s happening here. The two lines are now much closer together, meaning going from one variable to two seemed to improve our model. It’s not quite ready to bet your job on it, but now you can clearly see advertising made a contribution.\n",
        "\n",
        "Find an equation that can predict sales\n",
        "Our model with just price and advertising budget was doing better than price alone, but was still missing something because it incorporated only factors we had control over. In the real world, we aren’t in full control of the market, and we need to incorporate information about the outside world to have any hope of model accuracy.\n",
        "\n",
        "\n",
        "Here we’ve incorporated a variable denoting if the week was a holiday or not. This is called a binary variable, and it’s used to flag special time periods where conditions were different. For example in your model you might want to add a variable for ‘in lockdown from a global pandemic’ as a factor to determine what your sales would have been in a world without Coronavirus. We don’t have to use binary variables for external factors – for example it could be used to note whether your top selling product was in stock, the date you implemented a new marketing strategy, or the presence of a winning ad creative.\n",
        "\n",
        "Amazingly, with just three variables, the two lines are lining up almost perfectly. We shouldn’t expect every analysis we do to be this easy, nor should we plan to capture everything in our model. However we can use this example to illustrate how with a handful of predictive variables we can reveal some valuable insights into what drives sales for our business.\n",
        "\n",
        "Sales = -17 * Price + 16 * Advertising + 89 * Holiday + 415\n",
        "The equation the model gives us, shows what impact each factor had in driving sales. This is where decisions can be made and actions taken once we understand the implications of what this equation is telling us. The figures for sales and advertising budget are in thousands, so we can interpret the model coefficients as follows:\n",
        "\n",
        "Price had a negative impact of -17, meaning we lost $17,000 in sales revenue for every dollar we increased the price of our pies\n",
        "Advertising drove $16,000 in sales revenue for every thousand dollars spent, or our return on investment (ROI) was 16:1\n",
        "Holidays were good for our pie company, as we made an extra $89,000 in sales for every week where there was a holiday\n",
        "Our intercept was 415 or $415,000 in sales, meaning all things held equal, we’d get about this much in sales without these three variables\n",
        "Can we really trust the data?\n",
        "All models are a simplification of the real world, so by nature they’re wrong. For example there are thousands of variables that affect sales of pies, including the weather, competitor activity and the quality of your ad creative, none of which are captured here. Just because these three factors have been highly correlated to sales in the past, doesn’t mean that relationship will hold in the future. We might also mix up our correlations – in this data set adspend is highly correlated with holidays, so missing one of those variables overstates the effect of the other.\n",
        "\n",
        "However this is not a good excuse to go back to making gut decisions. Every decision we make models future outcomes with past data. We expect based on past experience that getting on the number 42 bus at the Tower of London will take us to Liverpool St Station in about 16 minutes. Yet that’s only a prediction, not a guarantee – there might be traffic, roadworks, or a change of route. Because your past data might be wrong, do you give up estimating travel time entirely?\n",
        "\n",
        "The difference between using your gut (where your brain models future outcomes based on past data) and a spreadsheet like the one we made (where a formula models future outcomes based on past data), is that the spreadsheet is transparent about how it's making those predictions. This means it can more easily be interrogated and improved.\n",
        "\n",
        "Ultimately the best test of a model is how well it improves your ability to take the right actions under uncertainty.Try and guess next month’s sales and see how you do versus the spreadsheet. Simple models like this one often reliably outperform humans, so I don’t fancy your chances. Instead I recommend spending that energy brainstorming ways the model might be wrong, and only using your judgement to deviate where you have conviction.\n",
        "\n",
        "How can you do multivariate regression in GSheets?\n",
        "The method I originally found in this video by Jalayer Academy used a Google Sheets add-on package called XLMiner, which was broken by Google’s move to verify apps in December 2019. Instead I adapted the method to use the native  LINEST function, which works well for our purposes.\n",
        "\n",
        "LINEST(known_data_y, known_data_x, [calculate_b], [verbose])\n",
        "known_data_y - this is the variable you want to predict, in our case sales\n",
        "known_data_x - the variable(s) you think can predict y (price, advertising, holiday)\n",
        "[calculate_b] - optional variable to calculate the intercept, default true\n",
        "[verbose] - optional variable to return all descriptive statistics, default false\n",
        "In our model it looks like this:\n",
        "\n",
        "\n",
        "You can see what these numbers look like if you just incorporate 1 variable, or expand to 2 variables. To adapt to your business simply create your own sheet with the same function but different data and variables and see what results you get. Be aware that for some reason the coefficients come out in backwards order!\n",
        "\n",
        "\n",
        "Once you have the coefficients you can plug them into a formula to be able to predict the number of sales for any combination. In the template we can see the coefficients given by the model in cells D23 through E23, and can put them together to construct our equation.\n",
        "\n",
        "Sales = -17 * Price + 16 * Advertising + 89 * Holiday + 415\n",
        "To get our charts we simply plugged back in the past data we had into this equation to see how close the prediction would be to the number of sales we actually saw. This let’s us determine the accuracy. Ideally you would then test the model by trying this equation on data it hasn’t seen yet, and see how well it does.\n",
        "\n",
        "Verbose output of descriptive statistics\n",
        "You’ll notice further down in the model at rows 25 to 42, we’re seeing what it looks like when you choose the ‘verbose’ output option with LINEST. Unless you’re working with statistics regularly you probably won’t know what these descriptions mean, but you can get pretty far by Googling each term and reading the Wikipedia page.\n",
        "\n",
        "The output is a little strange especially with the #NA fields, but don’t worry about them. Instead concentrate on the dictionary of descriptions I put together below in yellow. I have linked each value to these descriptions so you can interpret where this would go in your own spreadsheet.\n",
        "\n",
        "\n",
        "The main field which is important aside from the coefficients (which you get in the non-verbose version of the function) is the coefficient of determination, or the R-squared. This is the same as what you saw in the scatterplot showing Pie Sales vs Price, but this time it’s showing the variance predicted by the three variables you included in your regression analysis. It tells us that this model explains about 83% of the variance we see in sales – still some way to go, but pretty predictive considering the simplicity of the model.\n",
        "\n",
        "***Disclaimer – IANAS (I Am Not A Statistician)***\n",
        "I did get a Masters degree in Economics, and I’ve used these techniques in my work at Ladder and Saxifrage, but I’m not a professional statistician and there are gross oversimplifications in this post. I’m of the belief that any model is better than no model, so I still recommend you follow along and build your own. However if you’re doing this for any reasonably sized marketing budget ($100k+ per month), contact me and I can help connect you with an expert.\n",
        "\n",
        "Measuring long-lasting effects with adstocks\n",
        "Once you’ve built a simple model, you’ll naturally want to experiment with adding in complexity to see if that improves predictions. One common feature of Marketing Mix Models is a factor called ‘Adstocks’. The theory goes that some marketing channels like TV have a longer lasting brand advertising effect, so you need some way of incorporating this in your model.\n",
        "\n",
        "In practice the way this is calculated, is by assuming an ‘adstock rate’, which is the amount of spillover you get across time periods. An adstock rate of 50% from week to week means an effect as large as 50% of the adstock last week, is felt the week after the spend occurred. The formula then decays by 50% a week until the effect disappears.\n",
        "\n",
        "\n",
        "For the first time period, adstock is just equal to the advertising spend. For all other time periods, it equals the advertising budget for that week, plus the adstock rate multiplied by the prior week’s adstocks (which in week 2, would be week 1’s advertising budget). Adstocks is then used as a variable in the regression in place of advertising. Check out the second tab of our model to see how this works.\n",
        "\n",
        "\n",
        "With a relatively low adstock rate like 15%, it has the effect of smoothing out advertising budget, so the impact doesn’t drop off as quickly. In our model the marketing budget was always on, so the effect isn’t as clear as it might be for an advertiser running one-off TV campaigns.\n",
        "\n",
        "\n",
        "With a very high adstock rate like 50%, you can see the effect builds and stays high, which may or may not be realistic depending on the marketing channel and business. The trick is to experiment with multiple adstock rates until you find one that best fits the model. Typically brand advertising channels like TV, radio or PR might have longer effects than direct marketing channels like Google Ads, direct mail or cold email.\n",
        "\n",
        "\n",
        "In our model adstocks doesn’t seem to be a hugely important variable – with an adstock level of 15% we can increase the R-squared of the model from 0.836 to 0.839, but this is hardly worth including. In other models for other businesses correctly incorporating adstocks is the biggest determinant of model accuracy.\n",
        "\"\"\",\n",
        "\"\"\"\n",
        "What is Marketing Mix Modelling? 3 Benefits & Limitations\n",
        "Dominique Daly\n",
        "by Dominique Daly\n",
        "9 min read\n",
        "Jul 22, 2020\n",
        "\n",
        "\n",
        "\n",
        "\n",
        "\n",
        "\n",
        "There was a time when we considered traditional marketing practices, and the successes or failures they yield, as an art form. With mysterious, untraceable results, marketing efforts lacked-transparency and were widely regarded as being born out of the creative talents of star marketing professionals.\n",
        "\n",
        "The advent of big data changed things; substantial investment in data collection and analysis in the 1980s saw a shift in thinking toward marketing as being at least partly, if not wholly, scientific. To many marketers, however, the shift toward a full-blown scientific approach has been overwhelming. The new technologies, complex algorithms, and statistical applications often leave us scrambling to keep up.\n",
        "\n",
        "In retail industries, only 8-10% of sales revenue goes toward marketing activity; leaving CMOs and marketing managers to face the issue of how and where to invest their limited marketing budgets. Understandably, the biggest concern is how best to allocate this budget to a wide range of marketing activities. Methodical, strategic planning in the form of Marketing Mix Modelling (MMM) can help you overcome this problem, by finding the optimal mix of marketing variables and proving the return of investment (ROI) that your painstakingly-researched marketing strategy provides.\n",
        "\n",
        "\n",
        "7ps free template download\n",
        "\n",
        "\n",
        "What is Marketing Mix Modelling (MMM)?\n",
        "We all know about the 4Ps of the marketing mix: Product, Price, Place, Promotion. It’s a fundamental part of marketing theory that considers what factors are required for a business to succeed.\n",
        "\n",
        "\n",
        "\n",
        "The 4Ps of the Marketing Mix: Product. Price. Place. Promotion. Marketing Mix Modeling. Hurree.\n",
        "\n",
        "\n",
        "\n",
        "Well, marketing mix modelling is closely related to the 4Ps in that it seeks to determine how much success was generated by each factor, and forecast what future success can be created through altering and optimising the marketing mix.\n",
        "\n",
        "Marketing mix modelling is a statistical method of determining the effectiveness of marketing campaigns by breaking down aggregate data and differentiating between contributions from marketing tactics and promotional activities, and other uncontrollable drivers of success.\n",
        "\n",
        "The results, or ‘output’, of your marketing mix model analysis, will then inform the composition of future marketing efforts with a level of certainty, i.e. to change input ‘a’ will affect output ‘b.’\n",
        "\n",
        "\n",
        "Benefits of Marketing Mix Modelling\n",
        "Enables marketers to prove the ROI of their efforts\n",
        "Returns insights that allow for effective budget allocation\n",
        "Facilitates superior sales trend forecasting\n",
        "\n",
        "\n",
        "Limitations of Marketing Mix Modelling\n",
        "Lacks the convenience of real-time modern data analytics\n",
        "Critics argue that modern attribution methods are more effective as they consider 1 to 1, individual data\n",
        "Marketing Mix Modelling does not analyse customer experience (CX)\n",
        "\n",
        "\n",
        "How to get started with Marketing Mix Modelling?\n",
        "\n",
        "Okay, right now, I could get stuck into equations and coefficients and, you know, all the things that generally made you want to cry in high school mathematics class. But the thing is, as a marketing executive or manager, you’re far more likely to be pitching the benefits of implementing marketing mix modelling than actually crunching the numbers yourself... *phew*.\n",
        "\n",
        "So, instead, here’s what you need to know when trying to get a marketing mix modelling project off the ground within your department, so you can leave all the confusing stuff to the pros.\n",
        "\n",
        "\n",
        "\n",
        "Graph results: When did you start using MMM? Marketing Mix Modeling. Hurree.\n",
        "Source: iab\n",
        "\n",
        "\n",
        "\n",
        "Google suggests that before undertaking any Marketing Mix Modelling within your business or with a vendor, you need to prepare your organisation for what is to come. By following their 4 steps, you will ensure that your organisation gains value from your MMM project:\n",
        "\n",
        "\n",
        "Step 1: Establish goals\n",
        "\n",
        "Remember, the whole reason to undertake MMM in the first place is to gain systematic knowledge that will enhance your marketing efforts and optimise your budget allocation. But beyond this, your organisational goals need to be clear and achievable.\n",
        "\n",
        "Outline the key questions you want to answer through your marketing mix modelling. Some examples of areas to examine and questions to ask yourself may include:\n",
        "\n",
        "\n",
        "\n",
        "Budget\n",
        "Which marketing tactics have the best median return on investments (MROI)?\n",
        "\n",
        "Media\n",
        "Would increasing the TV advertising budget by 15% increase our incremental sales?\n",
        "\n",
        "Pricing\n",
        "What is the impact of a price change on sales and profits?\n",
        "\n",
        "Competitive\n",
        "Which competitors’ advertising campaigns are having the most significant impact on sales?\n",
        "\n",
        "\n",
        "\n",
        "The questions you ask your organisation during the preparation stages will subsequently guide the size and range of your MMM analysis and will help you to understand what data is needed to carry out your plans.\n",
        "\n",
        "\n",
        "\n",
        "Step 2: Align your organisation and key stakeholders to understand the data\n",
        "\n",
        "Marketing mix modelling requires you to collect a large amount of data from several different areas within your organisation. To do this, you will need to engage the gatekeepers of each data set, establish responsibilities, and create a timeline for data processing.\n",
        "\n",
        "Any number of these figures will likely need to be engaged:\n",
        "\n",
        "\n",
        "CMO (Chief Marketing Officer)\n",
        "TV and media agency partners\n",
        "Marketing agency partners\n",
        "CRM manager\n",
        "Marketing executives\n",
        "\n",
        "\n",
        "Step 3: Identify relevant data\n",
        "\n",
        "Your organisation will have existing data repositories; this is where your company and customer data is held to be easily accessed and analysed for research purposes. The quality of your data is an essential factor for MMM; data that is consistent, clean, and stored logically will save you time and effort when it comes to repurposing for your analysis. At this stage, you should enlist the help of any colleague responsible for managing organisational data repositories and tools.\n",
        "\n",
        "\n",
        "\n",
        "Step 4: Understand your access to data, including any limitations\n",
        "\n",
        "\n",
        "Create a detailed inventory of the data you hold and wish to involve in your analysis; try to gather as much information as possible, including any payments or subscriptions required to access third party data. You will also need to account for any time delays associated with accessing offline data.\n",
        "\n",
        "\n",
        "How to conduct marketing mix modelling?\n",
        "\n",
        "Nielsen points to 4 stages of the Marketing Mix Modelling process:\n",
        "\n",
        "\n",
        "Nielson: 4 Stages of Marketing Mix Modeling: Collect. Model. Analyze. Optimize.\n",
        "\n",
        "Source: Nielsen\n",
        "\n",
        "\n",
        "\n",
        "Stage 1: Collect\n",
        "Within the collection stage of marketing mix modelling, econometric techniques are used to estimate product demand produced by marketing tactics by separating product sales into 2 types of sales drivers:\n",
        "\n",
        "\n",
        "1. Incremental drivers\n",
        "\n",
        "These are the controllable elements implemented by the marketing team. Incremental drivers run on a short-term basis; data is captured on week-to-week sales that vary depending on:\n",
        "\n",
        "\n",
        "\n",
        "Above-the-line media activity (TV, print ads, digital ads, promotions, and discounts, etc.)\n",
        "Below-the-line factors (temporary selling prices, sales promotions, discounts, social media, direct mail marketing campaigns, in-store marketing, events, and conferences.)\n",
        "\n",
        "Above the Line Advertising: TV / RADIO / INTERNET. Below the Line Advertising: PROMOTION/DISCOUNT/COUPONS.\n",
        "\n",
        "\n",
        "\n",
        "2. Base drivers\n",
        "\n",
        "\n",
        "The base outcome for a business is the sales that are achieved in the absence of any incremental marketing activity. Base outcomes are often the result of brand equity and reputation that has been built up over several years, for example, customer loyalty.\n",
        "\n",
        "The following elements are base drivers:\n",
        "\n",
        "\n",
        "\n",
        "Price: The price of a product is a significant base driver of a marketing mix as price determines both the consumer segment that a product is targeted toward and the promotions which are implemented to market the product to the chosen audience.\n",
        "Distribution: The number of store locations, the stock within those locations, and the shelf life of that stock are all considered as base drivers of the marketing mix. Store locations and the inventory within them are static and can be discovered by customers without any marketing intervention.\n",
        "Seasonality: Certain variations happen periodically within a business year and can thus be relied upon to drive sales with a level of predictability. Seasonal sales, such as the winter holiday period, are huge drivers for the business. In 2018, for example, the eCommerce industry grew 16.7%, reaching up to $123.90 billion because of the holiday spending spree.\n",
        "Macroeconomic variables: macroeconomics is the study of how the overall economy and markets behave. It considers the impact of issues such as inflation, gross domestic product (GDP), unemployment, etc. When it comes to MMM, macroeconomic factors can have a significant impact on base sales, for example, an increase in unemployment rates will lower the purchasing power of consumers and, thus, sales will decrease.\n",
        "\n",
        "\n",
        "Pie Chart: Base & Incremental Drivers. Marketing Mix Modeling.\n",
        "\n",
        "Source: Exl Service\n",
        "\n",
        "\n",
        "\n",
        "Stage 2: Model\n",
        "P.M Cain calls the Time Series analysis (regression model) the “logical choice” for marketing mix modelling projects… If you’re scratching your head right now, don’t worry. Here’s a quick definition from the guys at MathWorks:\n",
        "\n",
        "“Time series regression is a statistical method for predicting a future response based on the response history (known as autoregressive dynamics) and the transfer of dynamics from relevant predictors. Time series regression can help you understand and predict the behaviour of dynamic systems from experimental or observational data. Time series regression is commonly used for modelling and forecasting of economic, financial, and biological systems.”\n",
        "\n",
        "Predicting the future sounds pretty cool, doesn’t it? Please, don’t tell anyone I said math was cool.\n",
        "\n",
        "Time-series regression analysis involves creating many different intervals of time and corresponding business results within these periods. The model is based upon the concept of Adstock, which dates way back to 1979 and describes the non-linear relationship between advertising and consumer behaviour.\n",
        "\n",
        "Adstock theory states that advertising is not immediate and has diminishing returns, meaning that its influential power decreases over time, even if more money is allocated to it. Therefore, time regression analysis will help marketers to understand the potential timeline for advertising effectiveness and how to optimise the marketing mix to compensate for these factors.\n",
        "\n",
        "It should be noted that this is just one of many models; depending on your organisational goals, the quality of your data, and the vendor that you choose to work with, a different model may be implemented.\n",
        "\n",
        "\n",
        "New call-to-action\n",
        "\n",
        "Stage 3: Analyse\n",
        "In the analysis stage, the outputs of your chosen model will be examined; these outputs will come in the form of decomposition of sales, which breaks the data down into volume for each modelled tactic.\n",
        "\n",
        "There are 3 significant metrics when it comes to analysing the decomposition of sales:\n",
        "\n",
        "\n",
        "Effectiveness\n",
        "Efficiency\n",
        "Median Return of Investment (MROI)\n",
        "\n",
        "You will be able to gain information on these metrics for your marketing efforts as a whole, and for each tactic individually.\n",
        "\n",
        "\n",
        "\n",
        "Decomposition of Sales flow chart. Marketing Mix Modeling. Hurree.\n",
        "Source: Neilsen\n",
        "\n",
        "\n",
        "Stage 4: Optimise\n",
        "\n",
        "\n",
        "This final stage of MMM essentially sees you turn your outputs into inputs - full circle style; meaning, you use the results of your analysis to optimise your marketing mix for future campaigns.\n",
        "\n",
        "Part of the optimisation will include a “what if” simulation. The outputs of your marketing model are equations that demonstrate the relationship between marketing activities and sales results. With these equations, you can predict what will happen if changes are made to the marketing mix.\n",
        "\n",
        "For example, “what if” I decrease the price of Coca Cola cans by 5%. This question considers how changes to incremental factors such as promotional discounts will impact sales, and your model output will return an accurate answer, which you can use to inform your promotions strategy.\n",
        "\n",
        "\n",
        "\n",
        "Simulation table of estimated profits based on Marketing Mix Model.\n",
        "Source: Ashokcharan\n",
        "\n",
        "\n",
        "\n",
        "Choosing a marketing mix modelling vendor\n",
        "\n",
        "\n",
        "Now that you have a clearer understanding of what marketing mix modelling is and what can be achieved with it, you should begin to consider which vendor you will use to handle your modelling. Unless that is, you have a statistical analysis whiz kid in-house at your organisation, in which case, off you go!\n",
        "\n",
        "During your research and consideration stages of finding the right vendor, here are some critical questions that you will want to ask:\n",
        "\n",
        "\n",
        "\n",
        "Question 1: Which sales drivers are included in the marketing mix model?\n",
        "Question 2: How is data collected?\n",
        "Question 3: What level of granularity are the data inputs?\n",
        "Question 4: How do you ensure the accuracy of the data inputs?\n",
        "Question 5: How granular are the insights?\n",
        "\n",
        "Without a thorough investigation into the vendor, you could end up with an analysis that lacks creativity and runs overtime with unplanned delays. Or worst-case scenario, you could end up with inaccurate data which fails to drive the actionable insights that you need to increase revenue and ROI.\n",
        "\n",
        "\n",
        "Summing Up\n",
        "\n",
        "If carried out correctly, MMM has the potential to streamline your marketing mix through fact-based optimisation. Using statistical data removes the guesswork from marketing activity, increasing ROI through precisely allocated budgets and accurately accounting for seasonal and channel-specific factors.\n",
        "\n",
        "In marketing, accurate data means more room to be creative with your content and more time to create a memorable customer experience (CX) for your audience. Investing in marketing mix modelling will give you the confidence to make decisive moves within your market and, ultimately, go further than your competitors.\n",
        "\"\"\",\n",
        "\"\"\"\n",
        "Marketing mix models are based in science, but also need a touch of art\n",
        "Prema Sampath, Stephen Mangan\n",
        "/\n",
        "September 2021\n",
        "Share\n",
        "Share\n",
        "Prema Sampath, group product manager at Google, leads a product team that develops measurement applications for brand advertising, including privacy-centric, third-party solutions for YouTube ads. Stephen Mangan is an ROI measurement manager at Google, leading research and measurement partner activations to help advertisers improve their media optimization strategies.\n",
        "\n",
        "Marketing mix models (MMM) help marketers make apples-to-apples comparisons across all of their different investments. They provide answers to questions like: What drove sales? What was my ROI? How do I optimize my marketing investment?\n",
        "\n",
        "But determining ROI takes more than a single calculation. Today’s media landscape is only becoming more fragmented and intertwined, presenting MMMs with an unprecedented challenge when predicting future performance.\n",
        "\n",
        "Incorporating business context to shape the MMM is an art, one with implications for the model’s outcomes and final recommendations.\n",
        "To make sense of the MMM, advertisers often defer to their measurement providers’ technical expertise. But there is more to the measurement strategy than the science behind the model. Incorporating business context to shape the MMM is an art, one with implications for the model’s outcomes and final recommendations. Advertisers who embrace that art can empower their businesses to make more strategic measurement-based decisions.\n",
        "\n",
        "Here are three steps marketers can take to embrace the art of the MMM.\n",
        "\n",
        "Start with granularity\n",
        "Remember that impressions are not equal across platforms or even within them. When it comes to video-specific measurement, MMMs will evaluate all of your impressions, but platforms can vary widely in terms of watch time, viewability, and audibility. The same data can produce very different results depending on how it’s incorporated into the model. Research we commissioned from Nielsen shows that when CPG brands’ MMMs evaluated individual video platforms rather than aggregated data, return on ad spend (ROAS) varied by as much as 48%.1\n",
        "\n",
        "Ad formats can vary just as widely. On YouTube, for example, ads can range from unskippable 30-second videos to a 6-second bumper ad. While both formats can deliver ROI, the cost and effectiveness of their impressions won’t be the same.\n",
        "\n",
        "The same data can produce very different results depending on how it’s incorporated into the model.\n",
        "So be sure to leverage the most granular data from your publishing partners, and your model will be able to identify the respective value of different impressions. As with any model, the MMM has limits. But every layer of granularity will lead to more informed business decisions.\n",
        "\n",
        "Add business context\n",
        "The science of the MMM can tell you what your ROI was, but it can’t tell you why without context. Getting granular, format-level data is a start, but formats are only one driver of ROI. According to Nielsen Catalina Solutions, creative accounts for 47% of video ROI — and yet, MMMs are not designed to evaluate individual creative assets.\n",
        "\n",
        "Collaboration will help your measurement provider evaluate how these changes in strategy impact ROI. Done right, this can lead to more ROI over time.\n",
        "\"If modeling is done in a vacuum, devoid of context, it could lead to misleading and suboptimal decisions,” said Rajika Karunanayaka, senior manager of media sciences at Hershey. “So context is just as important as the data that goes into modeling and should be a key consideration every step of the way.” Hershey’s Integrated Media team works with IRI to get data from Google and contextualize changes in their media plans, she said.\n",
        "\n",
        "Work with your publisher partner to gather insights around your media buy and identify any other data needed for the model to answer strategic business questions. Collaboration will help your measurement provider evaluate how these changes in strategy impact marketing ROI. Done right, this can lead to more ROI over time.\n",
        "\n",
        "6 factors can impact your ROI: 1. Creative; 2. Ad format mix; 3. Reach; 4. Frequency; 5. Audience strategy; 6. Viewability\n",
        "“We partner with Google to collect MMM data at the right level of granularity to enable actionable and insightful modeling, and then work with them to review the underlying executional elements that could potentially play into the results,” said Karunanayaka, citing changes to Hershey’s YouTube ad format mix, reach and frequency, audience strategy, and viewability as possible sites of impact. “We also work with our Google team to understand effectiveness at the creative level, while normalizing for ad format so we can get a sense of which Hershey YouTube ads are driving sales.”\n",
        "\n",
        "In an MMM meta-analysis we commissioned from Nielsen, on average, YouTube ROAS grew by 108% for brands after collaborating2 with Google, a 7X greater increase compared to brands that did not collaborate with Google.3 Sharing your media narrative will allow the modelers to understand what influenced changes in marketing ROI, and will ultimately help you formulate smarter business strategies.\n",
        "\n",
        "Create more transparency\n",
        "No model is perfect, MMM included. A team of Google data scientists even published a paper on how MMMs using the same data could report drastically different ROI with the same level of statistical confidence.\n",
        "\n",
        "With that in mind, assess results from a critical lens. Rather than accept all outputs, ask your measurement provider about the model’s margin of error for specific results and recommendations. Don’t base any important business decisions solely on your MMM as a single source of truth. Instead, take the time to design a test versus control experiment that can give you a second perspective on the model’s accuracy.\n",
        "\n",
        "The art of enhancing the model is where marketers can step in to help gather data and context from publisher partners and push providers on transparency.\n",
        "MMM is a valuable tool for measurement, but science alone cannot produce all the right answers. Nuance matters. The art of enhancing the model is where marketers can step in to help gather data and context from publisher partners and push providers on transparency. With these small steps, teams can influence the structure and enhance the accuracy of the MMM, leading to outcomes that enable more informed decision-making.\n",
        "\"\"\",\n",
        "\"\"\"\n",
        "WTF is marketing mix modeling?\n",
        "March 7, 2022 | By Kristina Monllos\n",
        "\n",
        "The job of the CMO has become even more challenging.\n",
        "\n",
        "More and more, success is tied to hard metrics like financial results. CMOs are having to show how various advertising and marketing tactics led someone to purchase their company’s product, as well as whether they drove softer metrics like raising people’s awareness of a brand. That proof has to convince CFOs — who still see marketing as a “cost center” despite CMOs’ best efforts — to maintain marketing budgets.\n",
        "\n",
        "One approach is to use marketing mix modeling, which allows CMOs to show business leadership how their efforts help the bottomline. “CFOs love it because a lot of analysis is done in silos,” said Jon Turner, global chief analytics officer at Mediahub, adding that those silos can add discrepancies into reporting. “With marketing mix modeling, you look holistically so it can’t explain more than what your sales actually are. It explains all the sales and allocates them to various marketing drivers.”\n",
        "\n",
        "Sure but what is marketing mix modeling?\n",
        "It’s a way of using statistical analysis as a tool to look back at sales over a period of time to determine what exactly caused those sales. Essentially, it’s a way of helping marketers and agency execs contextualize what’s working and what’s not. For example, say a marketer who typically spends the majority of their ad dollars on TV reallocated that spending to digital channels and offered a discounted product price. If that approach accounted for higher sales figures, that marketer could then take that analysis, tweak their approach and optimize it to spend more of their budget on what’s working and less on what’s not.\n",
        "\n",
        "Sounds like an obvious thing to do. How does it work?\n",
        "Marketers and agency execs input data to the analysis based on not only the marketing tactics they are using but each activity that a brand may deploy or encounter. So they’re not only accounting for digital, TV, out-of-home, radio, podcast and social media advertising but the price of a product and various promotions that are being run. Of course, that’s not all. That’d be too easy. They’re also accounting for things like inventory levels, seasonality, even shifting weather patterns — basically anything and everything that could impact sales. That data is then compared to previous sales data, often at least three years’ worth, to show how sales have changed and give a reason as to why they have changed. It’s correlation over causation.\n",
        "\n",
        "If that sounds like a vague synopsis, well, that’s because it is one. The model is specified for each brand and has to account for anything that would cause sales peaks for valleys.\n",
        "\n",
        "OK so it’s just another attribution method. Big whoop.\n",
        "Well, yes and no. While it is a way for marketers to point to a reason for sales, it’s also a predictive model to help marketers make decisions for the months ahead. Marketers will use the analysis — often on a quarterly basis — to see the shifts that are happening and move dollars around to hopefully continue positive trends. Should the model show that a particular channel is working more, they’ll likely move more marketing dollars there. Take out-of-home, for example. As people returned to travel and commuting following lockdowns, it’s become a more useful channel again so marketers are spending more there.\n",
        "\n",
        "But you just brought up the pandemic. Doesn’t that throw a wrench in the whole thing?\n",
        "In some ways but not really. That’s why marketers use a few years’ worth of data for marketing mix modeling. “When you have a shock to the system like Covid, having years’ worth of data becomes even more important,” explained Larry Davis-Swing, evp of advanced analytics at Spark Foundry. “By having plenty of data before it and plenty of data after you can start to understand and isolate all of the stuff you saw happening during Covid.”\n",
        "\n",
        "Davis-Swing continued: “When markets shut down, we saw consumer behavior shift. People went from going to restaurants to doing takeout and delivery. We saw delivery explode. So we can account for that initial explosion, not because of advertising or marketing, but because consumers had to change their behavior.”\n",
        "\n",
        "So yes, data from mid-March 2020 to the end of 2020 — maybe even summer 2021 — is a bit of a wash as consumer behavior changed significantly, making it harder for predictions to come to bear. However, as people get back out of their homes and return to pre-pandemic activities, marketers can then weigh the data from 2019 higher and factor more normal behaviors in to help future predictions be more accurate.\n",
        "\n",
        "That’s why you have to make sure the inputs are correct.\n",
        "Exactly. Marketers and agency execs have to think through everything that might account for sales variation so the model can work properly and help with predicting how they should be allocating their marketing mix. If you have a model that’s trying to explain the variation in champagne sales, you’re going to have to input a peak on New Year’s and Valentine’s Day, explained Trisha Pascale, group director of analytics at The Many. If you don’t account for that, the model could be inaccurate and the predictive element of it useless.\n",
        "\n",
        "Accounting for shifts in marketing and advertising strategies is important too. With the turnover of one CMO to another, which tends to happen every 18 months or so, there’s often a shift in strategy. If you haven’t accounted for more digital advertising or whatever the change may be in the marketing mix modeling, then it won’t show how that shift is working.\n",
        "\n",
        "OK but aren’t you using a bunch of data. What about the death of the cookie? Won’t that be a problem?\n",
        "Unlike multi-touch attribution, marketing mix modeling isn’t run at the consumer level, so the more personalized data that could go away with the death of the third-party cookie isn’t as important for marketing mix modeling.\n",
        "\n",
        "“We’re talking about really big trends, and we’re not building these models at the consumer level,” said Michael Salemme, svp of analytics at Zenith. “There are ways to run aggregate data to continue to run [marketing] mix modeling. We’re trying to explain changes in sales typically at a national or regional level, so we just need to know approximate exposures.”\n",
        "\"\"\",\n",
        "\"\"\"\n",
        "Market Mix Modeling (MMM) — 101\n",
        "\n",
        "Source: tvba.co.uk\n",
        "Market Mix Modeling (MMM) is a technique which helps in quantifying the impact of several marketing inputs on sales or Market Share. The purpose of using MMM is to understand how much each marketing input contributes to sales, and how much to spend on each marketing input.\n",
        "\n",
        "MMM helps in the ascertaining the effectiveness of each marketing input in terms of Return on Investment. In other words, a marketing input with higher return on Investment (ROI) is more effective as a medium than a marketing input with a lower ROI.\n",
        "\n",
        "MMM uses the Regression technique and the analysis performed through Regression is further used for extracting key information/insights.\n",
        "\n",
        "In this article, I will talk about various concepts associated with understanding MMM.\n",
        "\n",
        "1. Multi-Linear Regression:\n",
        "\n",
        "As mentioned earlier, Market Mix Modeling uses the principle of Multi-Linear Regression. The dependent variable could be Sales or Market Share. The independent variables usually used are Distribution, price, TV spends, outdoor campaigns spends, newspaper and magazine spends, below the line promotional spends, and Consumer promotions information etc. Nowadays, Digital medium is highly used by some marketers to increase brand awareness. So, inputs like Digital spends, website visitors etc. can also be used as inputs for MMM.\n",
        "\n",
        "An equation is formed between the dependent variables and predictors. This equation could be linear or non-linear depending on the relationship between the dependent variable and various marketing inputs. There are certain variables like TV advertisement which have a non-linear relationship with sales. This means that increase in TV GRP is not directly proportional to the increase in sales. I will discuss about this in more detail in the subsequent section.\n",
        "\n",
        "The betas generated from Regression analysis, help in quantifying the impact of each of the inputs. Basically, the beta depicts that one unit increase in the input value would increase the sales/profit by Beta units keeping the other marketing inputs constant.\n",
        "\n",
        "\n",
        "Sales Equation\n",
        "2. Linear and Non-Linear Impact of predictors:\n",
        "\n",
        "Certain variables show a linear relationship with Sales. This means as we increase these inputs, sales will keep on increasing. But variables like TV GRP do not have a linear impact on sales. Increase in TV GRPs will increase sales only to a certain extent. Once that saturation point is reached, every incremental unit of GRP would have a less impact on sales. So, some transformations are done on such non-linear variables to include them in linear models.\n",
        "\n",
        "TV GRP is considered as a non-linear variable because, according to marketers an advertisement will create awareness among customers to only a certain extent. Beyond a certain point, increased exposure to advertisement would not create any further incremental awareness among customers as they are already aware of the brand.\n",
        "\n",
        "\n",
        "So to consider TV GRP as one of the modeling inputs, it is transformed into adstock.\n",
        "\n",
        "TV Adstock has two components.\n",
        "\n",
        "a. Diminishing Returns: The underlying principle for TV advertisement is that the exposure to TV ads create awareness to a certain extent in the customers’ minds. Beyond that, the impact of exposure to ads starts diminishing over time. Each incremental amount of GRP would have a lower effect on Sales or awareness. So, the sales generated from incremental GRP start to diminish and become constant. This effect can be seen in the above graph, where the relationship between TV GRP and sales in non-linear. This type of relationship is captured by taking exponential or log of GRP.\n",
        "\n",
        "b. Carry over effect or Decay Effect: The impact of past advertisement on present sales is known as Carry over effect. A small component termed as lambda is multiplied with the past month GRP value. This component is also known as Decay effect as the impact of previous months’ advertisement decays over time.\n",
        "\n",
        "\n",
        "3. Base Sales and Incremental Sales:\n",
        "\n",
        "In Market Mix Modeling sales are divided into 2 components:\n",
        "\n",
        "a. Base Sales: Base Sales is what marketers get if they do not do any advertisement. It is sales due to brand equity built over the years. Base Sales are usually fixed unless there is some change in economic or environmental factors.\n",
        "\n",
        "b. Incremental Sales: Sales generated by marketing activities like TV advertisement, print advertisement, and digital spends, promotions etc. Total incremental sales is split into sales from each input to calculate contribution to total sales.\n",
        "\n",
        "4. Contribution Charts:\n",
        "\n",
        "Contribution charts are the easiest way to represent sales due to each marketing input. Contribution from each marketing input is product of its beta coefficient and input value.\n",
        "\n",
        "E.g.: Contribution from Newspaper = β* Newspaper Spends\n",
        "\n",
        "To compute contribution %, contribution due to each input is divided by the total contribution. I will elaborate on the interpretation of contribution charts in MMM 101 part 2.\n",
        "\n",
        "5. Deep Dives\n",
        "\n",
        "MMM results can be used further to perform deep dive analysis. Deep Dives can be used to assess the effectiveness of each campaign by understanding which campaigns or creatives work better than the other ones. It can be used to do a copy analysis of creatives by genre, language, channel etc.\n",
        "\n",
        "Insights from Deep Dives are considered for Budget optimization. Money is shifted from low performing channels or genres to high performing channels/genres to increase overall sales or market share.\n",
        "\n",
        "\n",
        "6. Budget Optimization\n",
        "\n",
        "For any business, Budget optimization is one of the key decisions to be taken for planning purposes.\n",
        "\n",
        "MMM assists marketers in optimizing future spends and maximizing effectiveness. Using MMM approach, it is established that which mediums are working better than the other ones. Then, budget allocation is done, by shifting money from low ROI mediums to high ROI mediums thus maximizing sales while keeping the budget constant.\n",
        "\n",
        "So folks, this was a brief about Market Mix Modeling.\n",
        "\"\"\",\n",
        "\"\"\"\n",
        "Marketing mix modeling\n",
        "\n",
        "Marketing mix modeling (MMM) is statistical analysis such as multivariate regressions on sales and marketing time series data to estimate the impact of various marketing tactics (marketing mix) on sales and then forecast the impact of future sets of tactics. It is often used to optimize advertising mix and promotional tactics with respect to sales revenue or profit.\n",
        "\n",
        "The techniques were developed by econometricians and were first applied to consumer packaged goods, since manufacturers of those goods had access to accurate data on sales and marketing support.[citation needed] Improved availability of data, massively greater computing power, and the pressure to measure and optimize marketing spend has driven the explosion in popularity as a marketing tool.[citation needed] In recent times MMM has found acceptance as a trustworthy marketing tool among the major consumer marketing companies.\n",
        "\n",
        "History\n",
        "The term marketing mix was developed by Neil Borden who first started using the phrase in 1949. “An executive is a mixer of ingredients, who sometimes follows a recipe as he goes along, sometimes adapts a recipe to the ingredients immediately available, and sometimes experiments with or invents ingredients no one else has tried.\" [1]\n",
        "\n",
        "According to Borden, \"When building a marketing program to fit the needs of his firm, the marketing manager has to weigh the behavioral forces and then juggle marketing elements in his mix with a keen eye on the resources with which he has to work.\" [2]\n",
        "\n",
        "E. Jerome McCarthy,[3] was the first person to suggest the four P's of marketing – price, promotion, product and place (distribution) – which constitute the most common variables used in constructing a marketing mix. According to McCarthy the marketers essentially have these four variables which they can use while crafting a marketing strategy and writing a marketing plan. In the long term, all four of the mix variables can be changed, but in the short term it is difficult to modify the product or the distribution channel.\n",
        "\n",
        "Another set of marketing mix variables were developed by Albert Frey[4] who classified the marketing variables into two categories: the offering, and process variables. The \"offering\" consists of the product, service, packaging, brand, and price. The \"process\" or \"method\" variables included advertising, promotion, sales promotion, personal selling, publicity, distribution channels, marketing research, strategy formation, and new product development.\n",
        "\n",
        "Recently, Bernard Booms and Mary Bitner built a model consisting of seven P's.[5] They added \"People\" to the list of existing variables, in order to recognize the importance of the human element in all aspects of marketing. They added \"process\" to reflect the fact that services, unlike physical products, are experienced as a process at the time that they are purchased. Desktop modeling tools such as Micro TSP have made this kind of statistical analysis part of the mainstream now. Most advertising agencies and strategy consulting firms offer MMM services to their clients.\n",
        "\n",
        "Marketing mix model\n",
        "Marketing mix modeling is an analytical approach that uses historic information, such as syndicated point-of-sale data and companies’ internal data, to quantify the sales impact of various marketing activities. Mathematically, this is done by establishing a simultaneous relation of various marketing activities with the sales, in the form of a linear or a non-linear equation, through the statistical technique of regression. MMM defines the effectiveness of each of the marketing elements in terms of its contribution to sales-volume, effectiveness (volume generated by each unit of effort), efficiency (sales volume generated divided by cost) and ROI. These learnings are then adopted to adjust marketing tactics and strategies, optimize the marketing plan and also to forecast sales while simulating various scenarios.\n",
        "\n",
        "This is accomplished by setting up a model with the sales volume/value as the dependent variable and independent variables created out of the various marketing efforts. The creation of variables for Marketing Mix Modeling is a complicated affair and is as much an art as it is a science. The balance between automated modeling tools crunching large data sets versus the artisan econometrician is an ongoing debate in MMM, with different agencies and consultants taking a position at certain points in this spectrum. Once the variables are created, multiple iterations are carried out to create a model which explains the volume/value trends well. Further validations are carried out, either by using a validation data, or by the consistency of the business results.\n",
        "\n",
        "The output can be used to analyze the impact of the marketing elements on various dimensions. The contribution of each element as a percentage of the total plotted year on year is a good indicator of how the effectiveness of various elements changes over the years. The yearly change in contribution is also measured by a due-to analysis which shows what percentage of the change in total sales is attributable to each of the elements. For activities like television advertising and trade promotions, more sophisticated analysis like effectiveness can be carried out. This analysis tells the marketing manager the incremental gain in sales that can be obtained by increasing the respective marketing element by one unit. If detailed spend information per activity is available then it is possible to calculate the Return on Investment of the marketing activity. Not only is this useful for reporting the historical effectiveness of the activity, it also helps in optimizing the marketing budget by identifying the most and least efficient marketing activities.\n",
        "\n",
        "Once the final model is ready, the results from it can be used to simulate marketing scenarios for a ‘What-if’ analysis. The marketing managers can reallocate this marketing budget in different proportions and see the direct impact on sales/value. They can optimize the budget by allocating spends to those activities which give the highest return on investment.\n",
        "\n",
        "Some MMM approaches like to include multiple products or brands fighting against each other in an industry or category model - where cross-price relationships and advertising share of voice is considered as important for wargaming.\n",
        "\n",
        "Components\n",
        "Marketing-mix models decompose total sales into two components:\n",
        "\n",
        "Base sales: This is the natural demand for the product driven by economic factors like pricing, long-term trends, seasonality, and also qualitative factors like brand awareness and brand loyalty.\n",
        "\n",
        "Incremental sales: Incremental sales are the component of sales driven by marketing and promotional activities. This component can be further decomposed into sales due to each marketing component like television advertising or radio advertising, print advertising (magazines, newspapers etc.), coupons, direct mail, Internet, feature or display promotions and temporary price reductions. Some of these activities have short-term returns (coupons, promotions), while others have longer term returns (TV, radio, magazine/print).\n",
        "\n",
        "Marketing-Mix analyses are typically carried out using linear regression modeling. Nonlinear and lagged effects are included using techniques like advertising adstock transformations. Typical output of such analyses include a decomposition of total annual sales into contributions from each marketing component, a.k.a. Contribution pie-chart.\n",
        "\n",
        "Yago.png\n",
        "Cyear.png\n",
        "Another standard output is a decomposition of year-over year sales growth/decline, a.k.a. ‘due-to charts’.\n",
        "\n",
        "Dueto.png\n",
        "Elements measured in MMM\n",
        "Base and incremental volume\n",
        "The very break-up of sales volume into base (volume that would be generated in absence of any marketing activity) and incremental (volume generated by marketing activities in the short run) across time gain gives wonderful insights. The base grows or declines across longer periods of time while the activities generating the incremental volume in the short run also impact the base volume in the long run. The variation in the base volume is a good indicator of the strength of the brand and the loyalty it commands from its users.\n",
        "\n",
        "Media and advertising\n",
        "Market mix modeling can determine the sales impact generated by individual media such as television, magazine, and online display ads. In some cases it can be used to determine the impact of individual advertising campaigns or even ad executions upon sales. For example, for TV advertising activity, it is possible to examine how each ad execution has performed in the market in terms of its impact on sales volume. MMM can also provide information on TV correlations at different media weight levels, as measured by gross rating points (GRP) in relation to sales volume response within a time frame, be it a week or a month. Information can also be gained on the minimum level of GRPs (threshold limit) in a week that need to be aired in order to make an impact, and conversely, the level of GRPs at which the impact on volume maximizes (saturation limit) and that the further activity does not have any payback. While not all MMM's will be able to produce definitive answers to all questions, some additional areas in which insights can sometimes be gained include: 1) the effectiveness of 15-second vis-à-vis 30-second executions; 2) comparisons in ad performance when run during prime-time vis-à-vis off-prime-time dayparts; 3) comparisons into the direct and the halo effect of TV activity across various products or sub-brands. The role of new product based TV activity and the equity based TV activity in growing the brand can also be compared. GRP's are converted into reach (i.e. GRPs are divided by the average frequency to get the percentage of people actually watching the advertisement). This is a better measure for modeling TV.\n",
        "\n",
        "Trade promotions\n",
        "Trade promotion is a key activity in every marketing plan. It is aimed at increasing sales in the short term by employing promotion schemes which effectively increases the customer awareness of the business and its products. The response of consumers to trade promotions is not straight forward and is the subject of much debate. Non-linear models exist to simulate the response. Using MMM we can understand the impact of trade promotion at generating incremental volumes. It is possible to obtain an estimate of the volume generated per promotion event in each of the different retail outlets by region. This way we can identify the most and least effective trade channels. If detailed spend information is available we can compare the Return on Investment of various trade activities like Every Day Low Price, Off-Shelf Display. We can use this information to optimize the trade plan by choosing the most effective trade channels and targeting the most effective promotion activity.\n",
        "\n",
        "Pricing\n",
        "Price increases of the brand impact the sales volume negatively. This effect can be captured through modeling the price in MMM. The model provides the price elasticity of the brand which tells us the percentage change in the sales for each percentage change in price. Using this, the marketing manager can evaluate the impact of a price change decision.\n",
        "\n",
        "Distribution\n",
        "For the element of distribution, we can know how the volume will move by changing distribution efforts or, in other words, by each percentage shift in the width or the depth of distribution. This can be identified specifically for each channel and even for each kind of outlet for off-take sales. In view of these insights, the distribution efforts can be prioritized for each channel or store-type to get the maximum out of the same. A recent study of a laundry brand showed that the incremental volume through 1% more presence in a neighborhood Kirana store is 180% greater than that through 1% more presence in a supermarket.[6] Based upon the cost of such efforts, managers identified the right channel to invest more for distribution.\n",
        "\n",
        "Launches\n",
        "When a new product is launched, the associated publicity and promotions typically results in higher volume generation than expected. This extra volume cannot be completely captured in the model using the existing variables. Often special variables to capture this incremental effect of launches are used. The combined contribution of these variables and that of the marketing effort associated with the launch will give the total launch contribution. Different launches can be compared by calculating their effectiveness and ROI.\n",
        "\n",
        "Competition\n",
        "The impact of competition on the brand sales is captured by creating the competition variables accordingly. The variables are created from the marketing activities of the competition like television advertising, trade promotions, product launches etc. The results from the model can be used to identify the biggest threat to own brand sales from competition. The cross-price elasticity and the cross-promotional elasticity can be used to devise appropriate response to competition tactics. A successful competitive campaign can be analyzed to learn valuable lesson for the own brand. television & Broadcasting: the application of MMM can also be applied in the broadcast media. Broadcasters may want to know what determine whether a particular will be sponsored. This could depend on the presenter attributes, the content, and the time the program is aired. these will therefore form the independent variables in our quest to design a program salability function. Program salabibility is a function of the presenter attributes, the program content and the time the program is aired.\n",
        "\n",
        "Studies in MMM\n",
        "Typical MMM studies provide the following insights\n",
        "\n",
        "Contribution by marketing activity\n",
        "ROI by marketing activity\n",
        "Effectiveness of marketing activity\n",
        "Optimal distribution of spends\n",
        "Learnings on how to execute each activity better e.g. optimal GRPs per week, optimal distribution between 15s and 30s, which promos to run, what SKUS to put on promotion etc.\n",
        "Adoption of MMM by the industry\n",
        "Over the past 20 years many large companies, particularly consumer packaged goods firms, have adopted MMM. Many Fortune 500 companies such as P&G, AT&T, Kraft, Coca-Cola and Pepsi have made MMM an integral part of their marketing planning. This has also been made possible due to the availability of specialist firms that are now providing MMM services.\n",
        "\n",
        "Marketing mix models were more popular initially in the CPG industry and quickly spread to Retail and Pharma industries because of the availability of Syndicated Data in these industries (primarily from Nielsen Company and IRI and to a lesser extent from NPD Group and Bottom Line Analytics and Gain Theory). Availability of Time-series data is crucial to robust modeling of marketing-mix effects and with the systematic management of customer data through CRM systems in other industries like Telecommunications, Financial Services, Automotive and Hospitality industries helped its spread to these industries. In addition competitive and industry data availability through third-party sources like Forrester Research's Ultimate Consumer Panel (Financial Services), Polk Insights (Automotive) and Smith Travel Research (Hospitality), further enhanced the application of marketing-mix modeling to these industries. Application of marketing-mix modeling to these industries is still in a nascent stage and a lot of standardization needs to be brought about especially in these areas:\n",
        "\n",
        "Interpretation of promotional activities across industries for e.g. promotions in CPG do not have lagged effects as they happen in-store, but automotive and hospitality promotions are usually deployed through the internet or through dealer marketing and can have longer lags in their impact. CPG promotions are usually absolute price discounts, whereas Automotive promotions can be cash-backs or loan incentives, and Financial Services promotions are usually interest rate discounts.\n",
        "Hospitality industry marketing has a very heavy seasonal pattern and most marketing-mix models will tend to confound marketing effectiveness with seasonality, thus overestimating or underestimating marketing ROI. Time-series Cross-Sectional models like 'Pooled Regression' need to be utilized, which increase sample size and variation and thus make a robust separation of pure marketing-effects from seasonality.\n",
        "Automotive Manufacturers spend a substantial amount of their marketing budgets on dealer advertising, which may not be accurately measurable if not modeled at the right level of aggregation. If modeled at the national level or even the market or DMA level, these effects may be lost in aggregation bias. On the other hand, going all the way down to dealer-level may overestimate marketing effectiveness as it would ignore consumer switching between dealers in the same area. The correct albeit rigorous approach would be to determine what dealers to combine into 'addable' common groups based on overlapping 'trade-areas' determined by consumer zip codes and cross-shopping information. At the very least 'Common Dealer Areas' can be determined by clustering dealers based on geographical distance between dealers and share of county sales. Marketing-mix models built by 'pooling' monthly sales for these dealer clusters will be effectively used to measure the impact of dealer advertising effectively.\n",
        "The proliferation of marketing-mix modeling was also accelerated due to the focus from Sarbanes-Oxley Section 404 that required internal controls for financial reporting on significant expenses and outlays. Marketing for consumer goods can be in excess of a 10th of total revenues and until the advent of marketing-mix models, relied on qualitative or 'soft' approaches to evaluate this spend. Marketing-mix modeling presented a rigorous and consistent approach to evaluate marketing-mix investments as the CPG industry had already demonstrated. A study by American Marketing Association pointed out that top management was more likely to stress the importance of marketing accountability than middle management, suggesting a top-down push towards greater accountability.\n",
        "\n",
        "Limitations\n",
        "While marketing mix models provide much useful information, there are two key areas in which these models have limitations that should be taken into account by all of those that use these models for decision making purposes. These limitations, discussed more fully below, include:\n",
        "\n",
        "1) the focus on short-term sales can significantly under-value the importance of longer-term equity building activities; and\n",
        "\n",
        "2) when used for media mix optimization, these models have a clear bias in favor of time-specific media (such as TV commercials) versus less time-specific media (such as ads appearing in monthly magazines); biases can also occur when comparing broad-based media versus regionally or demographically targeted media.\n",
        "\n",
        "In relation to the bias against equity building activities, marketing budgets optimized using marketing-mix models may tend too much towards efficiency because marketing-mix models measure only the short-term effects of marketing. Longer term effects of marketing are reflected in its brand equity. The impact of marketing spend on [brand equity] is usually not captured by marketing-mix models. One reason is that the longer duration that marketing takes to impact brand perception extends beyond the simultaneous or, at best, weeks-ahead impact of marketing on sales that these models measure. The other reason is that temporary fluctuation in sales due to economic and social conditions do not necessarily mean that marketing has been ineffective in building brand equity. On the contrary, it is very possible that in the short term sales and market-share could deteriorate, but brand equity could actually be higher. This higher equity should in the long run help the brand recover sales and market-share.\n",
        "\n",
        "Because marketing-mix models suggest a marketing tactic has a positive impact on sales doesn't necessarily mean it has a positive impact on long-term brand equity. Different marketing measures impact short-term and long-term brand sales differently and adjusting the marketing portfolio to maximize either the short-term or the long-term alone will be sub-optimal. For example, the short-term positive effect of promotions on consumers’ utility induces consumers to switch to the promoted brand, but the adverse impact of promotions on brand equity carries over from period to period. Therefore, the net effect of promotions on a brand’s market share and profitability can be negative due to their adverse impact on brand. Determining marketing ROI on the basis of marketing-mix models alone can lead to misleading results. This is because marketing-mix attempts to optimize marketing-mix to increase incremental contribution, but marketing-mix also drives brand-equity, which is not part of the incremental part measured by marketing-mix model- it is part of the baseline. True 'Return on Marketing Investment' is a sum of short-term and long-term ROI. The fact that most firms use marketing-mix models only to measure the short-term ROI can be inferred from an article by Booz Allen Hamilton, which suggests that there is a significant shift away from traditional media to 'below-the-line' spending, driven by the fact that promotional spending is easier to measure. But academic studies have shown that promotional activities are in fact detrimental to long-term marketing ROI (Ataman et al., 2006). Short-term marketing-mix models can be combined with brand-equity models using brand-tracking data to measure 'brand ROI', in both the short- and long-term. Finally, the modeling process itself should not be more costly than the resulting gain in profitability; i.e. it should have a positive Return On Modeling Effort (ROME).[7]\n",
        "\n",
        "The second limitation of marketing mix models comes into play when advertisers attempt to use these models to determine the best media allocation across different media types. The traditional use of MMM's to compare money spent on TV versus money spent on couponing was relatively valid in that both TV commercials and the appearance of coupons (for example, in a FSI run in a newspaper) were both quite time specific. However, as the use of these models has been expanded into comparisons across a wider range of media types, extreme caution should be used.\n",
        "\n",
        "Even with traditional media such as magazine advertising, the use of MMM's to compare results across media can be problematic; while the modelers overlay models of the 'typical' viewing curves of monthly magazines, these lack in precision, and thus introduce additional variability into the equation. Thus, comparisons of the effectiveness of running a TV commercial versus the effectiveness of running a magazine ad would be biased in favor of TV, with its greater precision of measurement. As new forms of media proliferate, these limitations become even more important to consider if MMM's are to be used in attempts to quantify their effectiveness. For example, Sponsorship Marketing, Sports Affinity Marketing, Viral Marketing, Blog Marketing and Mobile Marketing all vary in terms of the time-specificity of exposure.\n",
        "\n",
        "Further, most approaches to marketing-mix models try to include all marketing activities in aggregate at the national or regional level, but to the extent that various tactics are targeted to different demographic consumer groups, their impact may be lost. For example, Mountain Dew sponsorship of NASCAR may be targeted to NASCAR fans, which may include multiple age groups, but Mountain Dew advertising on gaming blogs may be targeted to the Gen Y population. Both of these tactics may be highly effective within the corresponding demographic groups but, when included in aggregate in a national or regional marketing-mix model, may come up as ineffective.\n",
        "\n",
        "Aggregation bias, along with issues relating to variations in the time-specific natures of different media, pose serious problems when these models are used in ways beyond those for which they were originally designed. As media become even more fragmented, it is critical that these issues are taken into account if marketing-mix models are used to judge the relative effectiveness of different media and tactics.\n",
        "\n",
        "Marketing-mix models use historical performance to evaluate marketing performance and so are not an effective tool to manage marketing investments for new products. This is because the relatively short history of new products make marketing-mix results unstable. Also relationship between marketing and sales may be radically different in the launch and stable periods. For example, the initial performance of Coke Zero was really poor and showed low advertising elasticity. In spite of this Coke increased its media spend, with an improved strategy and radically improved its performance resulting in advertising effectiveness that is probably several times the effectiveness during the launch period. A typical marketing-mix model would have recommended cutting media spend and instead resorting to heavy price discounting.\n",
        "\"\"\",\n",
        "]"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 24,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 105
        },
        "id": "JAWxUhmIe3yb",
        "outputId": "ee97e68d-a75a-491f-e901-485f8fedced2"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Media Mix Modeling (MMM) helped brands figure out which ads worked before online tracking existed. But now, because ads can change based on user behavior and sales happen both online and in stores, old models don’t work well. New tools like Recast fix this by measuring real ad impact across all channels.\n"
          ]
        }
      ],
      "source": [
        "# Summarize text\n",
        "text = texts[0]\n",
        "formatted_prompt = summary_prompt.format(text=text)\n",
        "response = submit_prompt(formatted_prompt)\n",
        "print(response)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 26,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "epw19DjVqjRx",
        "outputId": "0efccd0f-58ed-4eb2-f81d-93c8a76d6612"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Media Mix Modeling (MMM) helped brands figure out which ads boost sales before online tracking existed. Today, digital ads track clicks but often miscredit sales, especially with many ad channels and stores mixed in. New tools like Recast improve MMM for today’s complex, omni-channel marketing world.\n",
            "-----\n",
            "Econometrics uses math to figure out what really affects sales, like price, ads, or holidays. Big companies use it to see if their marketing works. You can even try simple models in Google Sheets to predict sales and make smarter business choices instead of guessing.\n",
            "-----\n",
            "Marketing Mix Modelling (MMM) is a way businesses use data to see which marketing efforts (like ads or discounts) actually help sales the most. It helps plan smarter budgets and predict sales, but it can be slow and doesn’t track individual customer experiences.\n",
            "-----\n",
            "Marketing mix models (MMM) help businesses see which ads work best by using data, but to get the full picture, marketers also need to add real-world details and teamwork. Combining science and art helps companies make smarter choices and get better results from their advertising.\n",
            "-----\n",
            "Marketing mix modeling helps companies figure out which ads and marketing efforts actually boost sales by analyzing lots of data like ads, prices, seasons, and even weather. It shows what works and helps plan smarter marketing, even through big changes like the pandemic.\n",
            "-----\n",
            "Market Mix Modeling (MMM) is a way to figure out how different marketing efforts like ads, promos, and prices affect sales. It uses math to show which ads work best and helps companies spend money wisely to get the most sales without wasting budget.\n",
            "-----\n",
            "Marketing mix modeling (MMM) uses math and data to see how ads, prices, and promotions affect sales. It helps companies spend money smarter by figuring out what works best. But MMM mostly shows short-term effects and might miss long-term brand impact or target group differences.\n",
            "-----\n"
          ]
        }
      ],
      "source": [
        "# summarize all articles\n",
        "all_responses = []\n",
        "\n",
        "for text in texts:\n",
        "    formatted_prompt = summary_prompt.format(text=text)\n",
        "    response = submit_prompt(formatted_prompt)\n",
        "    all_responses.append(response)\n",
        "    print(response)\n",
        "    print(\"-----\")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 27,
      "metadata": {
        "id": "1gN16HUWvZ2j"
      },
      "outputs": [],
      "source": [
        "wikipedia_texts = [\"\"\"Marketing mix modeling (MMM) is statistical analysis such as multivariate regressions on sales and marketing time series data to estimate the impact of various marketing tactics (marketing mix) on sales and then forecast the impact of future sets of tactics. It is often used to optimize advertising mix and promotional tactics with respect to sales revenue or profit.\n",
        "\n",
        "The techniques were developed by econometricians and were first applied to consumer packaged goods, since manufacturers of those goods had access to accurate data on sales and marketing support.[citation needed] Improved availability of data, massively greater computing power, and the pressure to measure and optimize marketing spend has driven the explosion in popularity as a marketing tool.[citation needed] In recent times MMM has found acceptance as a trustworthy marketing tool among the major consumer marketing companies.\"\"\"\n",
        ",\n",
        "\"\"\"\n",
        "History\n",
        "The term marketing mix was developed by Neil Borden who first started using the phrase in 1949. “An executive is a mixer of ingredients, who sometimes follows a recipe as he goes along, sometimes adapts a recipe to the ingredients immediately available, and sometimes experiments with or invents ingredients no one else has tried.\" [1]\n",
        "\n",
        "According to Borden, \"When building a marketing program to fit the needs of his firm, the marketing manager has to weigh the behavioral forces and then juggle marketing elements in his mix with a keen eye on the resources with which he has to work.\" [2]\n",
        "\n",
        "E. Jerome McCarthy,[3] was the first person to suggest the four P's of marketing – price, promotion, product and place (distribution) – which constitute the most common variables used in constructing a marketing mix. According to McCarthy the marketers essentially have these four variables which they can use while crafting a marketing strategy and writing a marketing plan. In the long term, all four of the mix variables can be changed, but in the short term it is difficult to modify the product or the distribution channel.\n",
        "\n",
        "Another set of marketing mix variables were developed by Albert Frey[4] who classified the marketing variables into two categories: the offering, and process variables. The \"offering\" consists of the product, service, packaging, brand, and price. The \"process\" or \"method\" variables included advertising, promotion, sales promotion, personal selling, publicity, distribution channels, marketing research, strategy formation, and new product development.\n",
        "\n",
        "Recently, Bernard Booms and Mary Bitner built a model consisting of seven P's.[5] They added \"People\" to the list of existing variables, in order to recognize the importance of the human element in all aspects of marketing. They added \"process\" to reflect the fact that services, unlike physical products, are experienced as a process at the time that they are purchased. Desktop modeling tools such as Micro TSP have made this kind of statistical analysis part of the mainstream now. Most advertising agencies and strategy consulting firms offer MMM services to their clients.\n",
        "\"\"\",\n",
        "\"\"\"\n",
        "Marketing mix model\n",
        "Marketing mix modeling is an analytical approach that uses historic information, such as syndicated point-of-sale data and companies’ internal data, to quantify the sales impact of various marketing activities. Mathematically, this is done by establishing a simultaneous relation of various marketing activities with the sales, in the form of a linear or a non-linear equation, through the statistical technique of regression. MMM defines the effectiveness of each of the marketing elements in terms of its contribution to sales-volume, effectiveness (volume generated by each unit of effort), efficiency (sales volume generated divided by cost) and ROI. These learnings are then adopted to adjust marketing tactics and strategies, optimize the marketing plan and also to forecast sales while simulating various scenarios.\n",
        "\n",
        "This is accomplished by setting up a model with the sales volume/value as the dependent variable and independent variables created out of the various marketing efforts. The creation of variables for Marketing Mix Modeling is a complicated affair and is as much an art as it is a science. The balance between automated modeling tools crunching large data sets versus the artisan econometrician is an ongoing debate in MMM, with different agencies and consultants taking a position at certain points in this spectrum. Once the variables are created, multiple iterations are carried out to create a model which explains the volume/value trends well. Further validations are carried out, either by using a validation data, or by the consistency of the business results.\n",
        "\n",
        "The output can be used to analyze the impact of the marketing elements on various dimensions. The contribution of each element as a percentage of the total plotted year on year is a good indicator of how the effectiveness of various elements changes over the years. The yearly change in contribution is also measured by a due-to analysis which shows what percentage of the change in total sales is attributable to each of the elements. For activities like television advertising and trade promotions, more sophisticated analysis like effectiveness can be carried out. This analysis tells the marketing manager the incremental gain in sales that can be obtained by increasing the respective marketing element by one unit. If detailed spend information per activity is available then it is possible to calculate the Return on Investment of the marketing activity. Not only is this useful for reporting the historical effectiveness of the activity, it also helps in optimizing the marketing budget by identifying the most and least efficient marketing activities.\n",
        "\n",
        "Once the final model is ready, the results from it can be used to simulate marketing scenarios for a ‘What-if’ analysis. The marketing managers can reallocate this marketing budget in different proportions and see the direct impact on sales/value. They can optimize the budget by allocating spends to those activities which give the highest return on investment.\n",
        "\n",
        "Some MMM approaches like to include multiple products or brands fighting against each other in an industry or category model - where cross-price relationships and advertising share of voice is considered as important for wargaming.\n",
        "\n",
        "Components\n",
        "Marketing-mix models decompose total sales into two components:\n",
        "\n",
        "Base sales: This is the natural demand for the product driven by economic factors like pricing, long-term trends, seasonality, and also qualitative factors like brand awareness and brand loyalty.\n",
        "\n",
        "Incremental sales: Incremental sales are the component of sales driven by marketing and promotional activities. This component can be further decomposed into sales due to each marketing component like television advertising or radio advertising, print advertising (magazines, newspapers etc.), coupons, direct mail, Internet, feature or display promotions and temporary price reductions. Some of these activities have short-term returns (coupons, promotions), while others have longer term returns (TV, radio, magazine/print).\n",
        "\n",
        "Marketing-Mix analyses are typically carried out using linear regression modeling. Nonlinear and lagged effects are included using techniques like advertising adstock transformations. Typical output of such analyses include a decomposition of total annual sales into contributions from each marketing component, a.k.a. Contribution pie-chart.\n",
        "\n",
        "Yago.png\n",
        "Cyear.png\n",
        "Another standard output is a decomposition of year-over year sales growth/decline, a.k.a. ‘due-to charts’.\n",
        "\n",
        "Dueto.png\n",
        "Elements measured in MMM\n",
        "Base and incremental volume\n",
        "The very break-up of sales volume into base (volume that would be generated in absence of any marketing activity) and incremental (volume generated by marketing activities in the short run) across time gain gives wonderful insights. The base grows or declines across longer periods of time while the activities generating the incremental volume in the short run also impact the base volume in the long run. The variation in the base volume is a good indicator of the strength of the brand and the loyalty it commands from its users.\n",
        "\n",
        "Media and advertising\n",
        "Market mix modeling can determine the sales impact generated by individual media such as television, magazine, and online display ads. In some cases it can be used to determine the impact of individual advertising campaigns or even ad executions upon sales. For example, for TV advertising activity, it is possible to examine how each ad execution has performed in the market in terms of its impact on sales volume. MMM can also provide information on TV correlations at different media weight levels, as measured by gross rating points (GRP) in relation to sales volume response within a time frame, be it a week or a month. Information can also be gained on the minimum level of GRPs (threshold limit) in a week that need to be aired in order to make an impact, and conversely, the level of GRPs at which the impact on volume maximizes (saturation limit) and that the further activity does not have any payback. While not all MMM's will be able to produce definitive answers to all questions, some additional areas in which insights can sometimes be gained include: 1) the effectiveness of 15-second vis-à-vis 30-second executions; 2) comparisons in ad performance when run during prime-time vis-à-vis off-prime-time dayparts; 3) comparisons into the direct and the halo effect of TV activity across various products or sub-brands. The role of new product based TV activity and the equity based TV activity in growing the brand can also be compared. GRP's are converted into reach (i.e. GRPs are divided by the average frequency to get the percentage of people actually watching the advertisement). This is a better measure for modeling TV.\n",
        "\n",
        "Trade promotions\n",
        "Trade promotion is a key activity in every marketing plan. It is aimed at increasing sales in the short term by employing promotion schemes which effectively increases the customer awareness of the business and its products. The response of consumers to trade promotions is not straight forward and is the subject of much debate. Non-linear models exist to simulate the response. Using MMM we can understand the impact of trade promotion at generating incremental volumes. It is possible to obtain an estimate of the volume generated per promotion event in each of the different retail outlets by region. This way we can identify the most and least effective trade channels. If detailed spend information is available we can compare the Return on Investment of various trade activities like Every Day Low Price, Off-Shelf Display. We can use this information to optimize the trade plan by choosing the most effective trade channels and targeting the most effective promotion activity.\n",
        "\n",
        "Pricing\n",
        "Price increases of the brand impact the sales volume negatively. This effect can be captured through modeling the price in MMM. The model provides the price elasticity of the brand which tells us the percentage change in the sales for each percentage change in price. Using this, the marketing manager can evaluate the impact of a price change decision.\n",
        "\n",
        "Distribution\n",
        "For the element of distribution, we can know how the volume will move by changing distribution efforts or, in other words, by each percentage shift in the width or the depth of distribution. This can be identified specifically for each channel and even for each kind of outlet for off-take sales. In view of these insights, the distribution efforts can be prioritized for each channel or store-type to get the maximum out of the same. A recent study of a laundry brand showed that the incremental volume through 1% more presence in a neighborhood Kirana store is 180% greater than that through 1% more presence in a supermarket.[6] Based upon the cost of such efforts, managers identified the right channel to invest more for distribution.\n",
        "\n",
        "Launches\n",
        "When a new product is launched, the associated publicity and promotions typically results in higher volume generation than expected. This extra volume cannot be completely captured in the model using the existing variables. Often special variables to capture this incremental effect of launches are used. The combined contribution of these variables and that of the marketing effort associated with the launch will give the total launch contribution. Different launches can be compared by calculating their effectiveness and ROI.\n",
        "\n",
        "Competition\n",
        "The impact of competition on the brand sales is captured by creating the competition variables accordingly. The variables are created from the marketing activities of the competition like television advertising, trade promotions, product launches etc. The results from the model can be used to identify the biggest threat to own brand sales from competition. The cross-price elasticity and the cross-promotional elasticity can be used to devise appropriate response to competition tactics. A successful competitive campaign can be analyzed to learn valuable lesson for the own brand. television & Broadcasting: the application of MMM can also be applied in the broadcast media. Broadcasters may want to know what determine whether a particular will be sponsored. This could depend on the presenter attributes, the content, and the time the program is aired. these will therefore form the independent variables in our quest to design a program salability function. Program salabibility is a function of the presenter attributes, the program content and the time the program is aired.\n",
        "\"\"\",\n",
        "\"\"\"\n",
        "Adoption of MMM by the industry\n",
        "Over the past 20 years many large companies, particularly consumer packaged goods firms, have adopted MMM. Many Fortune 500 companies such as P&G, AT&T, Kraft, Coca-Cola and Pepsi have made MMM an integral part of their marketing planning. This has also been made possible due to the availability of specialist firms that are now providing MMM services.\n",
        "\n",
        "Marketing mix models were more popular initially in the CPG industry and quickly spread to Retail and Pharma industries because of the availability of Syndicated Data in these industries (primarily from Nielsen Company and IRI and to a lesser extent from NPD Group and Bottom Line Analytics and Gain Theory). Availability of Time-series data is crucial to robust modeling of marketing-mix effects and with the systematic management of customer data through CRM systems in other industries like Telecommunications, Financial Services, Automotive and Hospitality industries helped its spread to these industries. In addition competitive and industry data availability through third-party sources like Forrester Research's Ultimate Consumer Panel (Financial Services), Polk Insights (Automotive) and Smith Travel Research (Hospitality), further enhanced the application of marketing-mix modeling to these industries. Application of marketing-mix modeling to these industries is still in a nascent stage and a lot of standardization needs to be brought about especially in these areas:\n",
        "\n",
        "Interpretation of promotional activities across industries for e.g. promotions in CPG do not have lagged effects as they happen in-store, but automotive and hospitality promotions are usually deployed through the internet or through dealer marketing and can have longer lags in their impact. CPG promotions are usually absolute price discounts, whereas Automotive promotions can be cash-backs or loan incentives, and Financial Services promotions are usually interest rate discounts.\n",
        "Hospitality industry marketing has a very heavy seasonal pattern and most marketing-mix models will tend to confound marketing effectiveness with seasonality, thus overestimating or underestimating marketing ROI. Time-series Cross-Sectional models like 'Pooled Regression' need to be utilized, which increase sample size and variation and thus make a robust separation of pure marketing-effects from seasonality.\n",
        "Automotive Manufacturers spend a substantial amount of their marketing budgets on dealer advertising, which may not be accurately measurable if not modeled at the right level of aggregation. If modeled at the national level or even the market or DMA level, these effects may be lost in aggregation bias. On the other hand, going all the way down to dealer-level may overestimate marketing effectiveness as it would ignore consumer switching between dealers in the same area. The correct albeit rigorous approach would be to determine what dealers to combine into 'addable' common groups based on overlapping 'trade-areas' determined by consumer zip codes and cross-shopping information. At the very least 'Common Dealer Areas' can be determined by clustering dealers based on geographical distance between dealers and share of county sales. Marketing-mix models built by 'pooling' monthly sales for these dealer clusters will be effectively used to measure the impact of dealer advertising effectively.\n",
        "The proliferation of marketing-mix modeling was also accelerated due to the focus from Sarbanes-Oxley Section 404 that required internal controls for financial reporting on significant expenses and outlays. Marketing for consumer goods can be in excess of a 10th of total revenues and until the advent of marketing-mix models, relied on qualitative or 'soft' approaches to evaluate this spend. Marketing-mix modeling presented a rigorous and consistent approach to evaluate marketing-mix investments as the CPG industry had already demonstrated. A study by American Marketing Association pointed out that top management was more likely to stress the importance of marketing accountability than middle management, suggesting a top-down push towards greater accountability.\n",
        "\"\"\",\n",
        "\"\"\"\n",
        "Limitations\n",
        "While marketing mix models provide much useful information, there are two key areas in which these models have limitations that should be taken into account by all of those that use these models for decision making purposes. These limitations, discussed more fully below, include:\n",
        "\n",
        "1) the focus on short-term sales can significantly under-value the importance of longer-term equity building activities; and\n",
        "\n",
        "2) when used for media mix optimization, these models have a clear bias in favor of time-specific media (such as TV commercials) versus less time-specific media (such as ads appearing in monthly magazines); biases can also occur when comparing broad-based media versus regionally or demographically targeted media.\n",
        "\n",
        "In relation to the bias against equity building activities, marketing budgets optimized using marketing-mix models may tend too much towards efficiency because marketing-mix models measure only the short-term effects of marketing. Longer term effects of marketing are reflected in its brand equity. The impact of marketing spend on [brand equity] is usually not captured by marketing-mix models. One reason is that the longer duration that marketing takes to impact brand perception extends beyond the simultaneous or, at best, weeks-ahead impact of marketing on sales that these models measure. The other reason is that temporary fluctuation in sales due to economic and social conditions do not necessarily mean that marketing has been ineffective in building brand equity. On the contrary, it is very possible that in the short term sales and market-share could deteriorate, but brand equity could actually be higher. This higher equity should in the long run help the brand recover sales and market-share.\n",
        "\n",
        "Because marketing-mix models suggest a marketing tactic has a positive impact on sales doesn't necessarily mean it has a positive impact on long-term brand equity. Different marketing measures impact short-term and long-term brand sales differently and adjusting the marketing portfolio to maximize either the short-term or the long-term alone will be sub-optimal. For example, the short-term positive effect of promotions on consumers’ utility induces consumers to switch to the promoted brand, but the adverse impact of promotions on brand equity carries over from period to period. Therefore, the net effect of promotions on a brand’s market share and profitability can be negative due to their adverse impact on brand. Determining marketing ROI on the basis of marketing-mix models alone can lead to misleading results. This is because marketing-mix attempts to optimize marketing-mix to increase incremental contribution, but marketing-mix also drives brand-equity, which is not part of the incremental part measured by marketing-mix model- it is part of the baseline. True 'Return on Marketing Investment' is a sum of short-term and long-term ROI. The fact that most firms use marketing-mix models only to measure the short-term ROI can be inferred from an article by Booz Allen Hamilton, which suggests that there is a significant shift away from traditional media to 'below-the-line' spending, driven by the fact that promotional spending is easier to measure. But academic studies have shown that promotional activities are in fact detrimental to long-term marketing ROI (Ataman et al., 2006). Short-term marketing-mix models can be combined with brand-equity models using brand-tracking data to measure 'brand ROI', in both the short- and long-term. Finally, the modeling process itself should not be more costly than the resulting gain in profitability; i.e. it should have a positive Return On Modeling Effort (ROME).[7]\n",
        "\n",
        "The second limitation of marketing mix models comes into play when advertisers attempt to use these models to determine the best media allocation across different media types. The traditional use of MMM's to compare money spent on TV versus money spent on couponing was relatively valid in that both TV commercials and the appearance of coupons (for example, in a FSI run in a newspaper) were both quite time specific. However, as the use of these models has been expanded into comparisons across a wider range of media types, extreme caution should be used.\n",
        "\n",
        "Even with traditional media such as magazine advertising, the use of MMM's to compare results across media can be problematic; while the modelers overlay models of the 'typical' viewing curves of monthly magazines, these lack in precision, and thus introduce additional variability into the equation. Thus, comparisons of the effectiveness of running a TV commercial versus the effectiveness of running a magazine ad would be biased in favor of TV, with its greater precision of measurement. As new forms of media proliferate, these limitations become even more important to consider if MMM's are to be used in attempts to quantify their effectiveness. For example, Sponsorship Marketing, Sports Affinity Marketing, Viral Marketing, Blog Marketing and Mobile Marketing all vary in terms of the time-specificity of exposure.\n",
        "\n",
        "Further, most approaches to marketing-mix models try to include all marketing activities in aggregate at the national or regional level, but to the extent that various tactics are targeted to different demographic consumer groups, their impact may be lost. For example, Mountain Dew sponsorship of NASCAR may be targeted to NASCAR fans, which may include multiple age groups, but Mountain Dew advertising on gaming blogs may be targeted to the Gen Y population. Both of these tactics may be highly effective within the corresponding demographic groups but, when included in aggregate in a national or regional marketing-mix model, may come up as ineffective.\n",
        "\n",
        "Aggregation bias, along with issues relating to variations in the time-specific natures of different media, pose serious problems when these models are used in ways beyond those for which they were originally designed. As media become even more fragmented, it is critical that these issues are taken into account if marketing-mix models are used to judge the relative effectiveness of different media and tactics.\n",
        "\n",
        "Marketing-mix models use historical performance to evaluate marketing performance and so are not an effective tool to manage marketing investments for new products. This is because the relatively short history of new products make marketing-mix results unstable. Also relationship between marketing and sales may be radically different in the launch and stable periods. For example, the initial performance of Coke Zero was really poor and showed low advertising elasticity. In spite of this Coke increased its media spend, with an improved strategy and radically improved its performance resulting in advertising effectiveness that is probably several times the effectiveness during the launch period. A typical marketing-mix model would have recommended cutting media spend and instead resorting to heavy price discounting.\n",
        "\"\"\"]"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 28,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "xfkKe2f3we4M",
        "outputId": "d35de1e5-6a41-4eea-b820-701e74f801f3"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Marketing mix modeling (MMM) uses math to study how different marketing actions, like ads and promotions, affect sales. It helps companies decide the best way to spend money on marketing to boost sales or profits. It became popular because of better data and faster computers.\n",
            "-----\n",
            "Marketing mix is a way to plan how to sell things. It started in 1949 with Neil Borden. The most famous idea is the 4 P’s: Price, Promotion, Product, and Place. Later, others added more parts like People and Process to help businesses sell better and understand customers.\n",
            "-----\n",
            "Marketing Mix Modeling (MMM) uses past sales and marketing data to find out how different ads, prices, and promotions affect sales. It helps companies see what works best, improve their marketing plans, and predict future sales by creating math models. This helps them spend money smarter and sell more.\n",
            "-----\n",
            "Over 20 years, big companies like Coca-Cola and Pepsi started using Marketing Mix Models (MMM) to plan ads better. It began in consumer goods but spread to retail, pharma, and more thanks to data and tech. Different industries face unique challenges, so MMM is still evolving to improve accuracy.\n",
            "-----\n",
            "Marketing mix models help understand marketing impact but have limits. They focus on short-term sales, missing long-term brand building. They can favor TV ads over less time-specific media and miss effects on targeted groups. Also, they aren’t great for new products with little history.\n",
            "-----\n"
          ]
        }
      ],
      "source": [
        "# Summarize all sections in wikipedia\n",
        "all_wikipedia_responses = []\n",
        "\n",
        "for text in wikipedia_texts:\n",
        "    formatted_prompt = summary_prompt.format(text=text)\n",
        "    response = submit_prompt(formatted_prompt)\n",
        "    all_wikipedia_responses.append(response)\n",
        "    print(response)\n",
        "    print(\"-----\")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 30,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 70
        },
        "id": "NwtkcsLrwoPA",
        "outputId": "e10065a0-9f66-4ced-dbbd-84a15c51f583"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Marketing mix modeling uses math to see how ads, prices, and promos affect sales. It helps companies spend marketing money smarter and sell more. It started with the 4 P’s: Price, Product, Promotion, Place. Big brands use it, but it’s not perfect for long-term or new products.\n"
          ]
        }
      ],
      "source": [
        "# Aggregate the summaries for wikipedia\n",
        "text = \"\\n\".join(all_wikipedia_responses)\n",
        "formatted_prompt = summary_prompt.format(text=text)\n",
        "response = submit_prompt(formatted_prompt)\n",
        "\n",
        "all_responses.append(response)\n",
        "\n",
        "print(response)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 31,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "abL4LvDGxrvm",
        "outputId": "85260ff6-63f2-4ebb-963d-fced028614cb"
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "2498"
            ]
          },
          "execution_count": 31,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "len(\"\\n\".join(all_responses))"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 33,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 70
        },
        "id": "0JYi6IKDw5ju",
        "outputId": "b711bb30-93a5-4cf3-e8b5-a2cff67080dc"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Marketing Mix Modeling (MMM) uses math to figure out which ads and marketing actions really help sales. It helps companies spend money smarter by analyzing things like price, ads, and seasons. Though it's great for short-term results, it can miss long-term effects or new trends.\n"
          ]
        }
      ],
      "source": [
        "# aggregate the summaries for all texts\n",
        "text = \"\\n\".join(all_responses)\n",
        "formatted_prompt = summary_prompt.format(text=text)\n",
        "response = submit_prompt(formatted_prompt)\n",
        "print(response)"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.11.5"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
