Simulated Economy Tutorial

(jasonfantl.com)

103 points | by jfantl 1 day ago

12 comments

  • jgord 1 day ago
    Just as we have weather forecasting, climate models .. we do need and should have good fine-grain computational models of complex systems such as the cell .. and the global economy.

    We should be able to have whole economy simulations give reasonable predictions in response to natural events and lever-pulling such as :

    - higher progressive tax rates - central bank interest rate moves - local tariffs and sanctions - shipping blackades / blockages - regional war - extreme weather events - earthquake - regional epidemic - giving poor people cash grants - free higher education - science research grants - skilled immigration / emigration

    But .. of course this would require something like a rich country providing grants to applied cross disciplinary research over many years.

    It might even lead to insights that prevent semi-regular economic boom and bust cycles we experienced the past 100 years.

    • noosphr 22 hours ago
      >we do need and should have good fine-grain computational models of complex systems such [...] the global economy.

      Many years ago when 'social graphs' were still a hot area to do research in I started building a simulation of the equivalent of a small medieval village.

      What became quickly apparent is that you didn't just need interactions between any two individuals like classical social graphs talked about, but between any number of arbitrary groups of individuals. Otherwise something as simple as an extended family couldn't be modeled.

      That meant that instead of being able to use a matrix as the fundamental data structure you'd need a tensor of rank N, where N is the number of people in the economy. Just to see how intractable this is if the village had 20 people in it with the traditional matrix approach you'd need 400 weights to model interactions. With the tensor approach you need ~1e+26.

      In short: it's impossible to have fined grained simulations of complex societies. The best we can do is drastic over simplifications that give us _some_ predictive power.

      • abdullahkhalids 21 hours ago
        A set of size N=20, has total number of subsets equal to 2^N = 1.05 million. You must have had other degrees of freedom to bump that to 1E26.
        • noosphr 21 hours ago
          That's only for two way relationships, you need N way relationships, which is N^N.
          • wordpad 21 hours ago
            Wouldn't you be able to quickly prune away invalid/unlikely interactions? Maybe, have some cutoff based on proximity of members or something?
            • noosphr 21 hours ago
              Yes, the resulting tensor is incredibly sparse, but still too large to ever be practical for use as anything but the theoretical upper limit on the complexity of a model.

              The issue is that while you can remove pretty much all possible interactions for a specific case you have no idea where an interaction could pop up unexpectedly with a huge impact ahead of time.

              For the medieval theme the leader of the village may be a cousin of the king which is a very distant but very strong interaction.

              • exe34 20 hours ago
                how many people do you talk to in a day?
                • noosphr 19 hours ago
                  This is a perfect example of the limitations of old school social graphs. The number of people you talk to is just the first order effect. What about all the people that people in your company talked to? That has a non zero economic impact on you. Similarly for any other company that your company talks to, and so on and so on.
                  • exe34 18 hours ago
                    that still scales linearly with number of people, not quadratically.
                    • noosphr 14 hours ago
                      It scales super exponentially since each person is a member of an arbitrary number of groups and their actions have some non zero impact on each other member of the groups they are a member of, and each individual in each group with a member of which they have interacted with.
                      • exe34 6 hours ago
                        if that were the case, numerical weather prediction wouldn't work. you can add up the impact for each neighbour.
                        • noosphr 4 hours ago
                          Humans are not mindless molecules whose only interactions are with the people right next to them.
    • onlyrealcuzzo 1 day ago
      We already have tons of those models.

      None of them are perfect.

      And they never will be.

      Could the be better? Yes.

      The problem is, you won't really know they're better until post-ex. And even then, you'll never be sure how much better. They're always bound to fail catastrophically at some point. Etc.

      • littlestymaar 20 hours ago
        In fairness we don't really have such models, at least not anymore.

        We used to, that's what “macro” economics was about. The models where crude but they did the job for a while, we used them for more than 30 years between the 40s and the late 70s, with great success (no economic crisis for the longest time since the industrial revolution).

        But they conflicted with the idea that economist made of their job, as these models didn't include any if the classical economics credo that economists had been worshipping for almost two centuries (markets, competition, scarcity, supply and demand, etc.). So people started building “micro-founded” macro models, that tried to reconcile the empirical models that worked with the ideological principles of classical economics. But you can't have good models if you design them to match an ideological paradigm.

        And then as you said, it failed catastrophically: the oil shock came, and suddenly the forecasts of the models became useless for a while. At that very moment, everyone who opposed to using models to justify state intervention where thrilled, and the era of short-terms economic engineering based on models was dead.

    • dmbche 19 hours ago
      You've stumbled upon Chaos Theory (https://en.m.wikipedia.org/wiki/Chaos_theory), which aims to study chaotic systems (charactesised by very high relation to initial variables - see weather prediction, double pendulum, etc).

      Some problems are too sensible to initial variables and solutions are not prescriptive like regular physics - meaning that variability at the 20th decimal in your initial variables will induce massive output differences. Lorentz discovery of this is interesting as he was working on weather modelling, it's a clear example of the issues with chaotic systems. He was running simulations of weather systems with multiple fixed initial variables (temperature, wind speed, etc) and seeing how the system progressed over a few hours. He realised that after a typo on a very far away decimal on a single parameter, the system was modelling the complete opposite of what we had seen in the previous test (think it was forecasting a typhoon when it used to say sunny day), even while using values that would be "equal" with relation to the precision of the measuring equipement. And that's nothing to talk about getting clean, precise enough data for such models, which is practically impossible (see the observer effect, between other causes). Garbage in, garbage out.

      All this to say that problems in this sphere are characterized by quickly becoming untractable and impossible to model precisely how they evolve over time.

      I can recommend James Gleick's Chaos: Making a new science for a overview for the layperson.

    • _carbyau_ 4 hours ago
      Issue of the Commons.

      Weather models are good because if we know about it the weather doesn't care and doesn't change what it is going to do.

      Anyone who has an accurate financial model is keeping it to themselves.

      Anyone who has an accurate financial model and make it public... invalidates their model as everyone takes that information and plans to take advantage of it accordingly.

    • huitzitziltzin 1 day ago
      There’s a whole discipline which does nearly that, though they do not use this style of agent based model.

      Generally agent based models have numerous parameters which can take many values (endowments, preferences) and the models don’t themselves give any guidance about how to set the parameters. Theory can give limited guidance (eg., that function is concave, this parameter is negative). Sometimes we have experimental data though its generalizability beyond the lab is uncertain.

      What you want to do to create a scientific macroeconomics is to work backwards from the data you see in the economy (aggregate consumption, investment, etc.) and how you know the aggregates were generated (via the behavior of a lot of individual agents), and an equilibrium assumption to recover the parameters.

      If you know the parameters of the model you assume, you can then simulate interesting counterfactuals. (And yes you assume the model - a “full” model including “all” of the individual endowments and parameters you can think of is completely intractable. You have to simplify.)

      You’ll never get that out of the author’s computer game.

      If you want references to the macro literature it’s enormous and I can provide them.

      • nxobject 8 hours ago
        Would you happen to know what some key search phrases might be to get started in the contemporary modeling literature?
        • huitzitziltzin 2 hours ago
          Sure it’s just macro.

          Ljungqvist and Sargent is a standard grad level text.

          Acemoglu has one with a growth focus.

          Miao is another one.

          Stachurski and Sargent is one focused on computational issues.

          Stokey Lucas and Prescott is the math but I would skip that.

          Dejong and Dave covers macroeconometrics.

      • littlestymaar 19 hours ago
        > and an equilibrium assumption to recover the parameters

        That parts makes no sense though, there isn't an equilibrium and can never be, economies are a chaotic system. One of the key problems of economic modeling is that they used mathematical tool that aren't suited for that.

        You can't consider an economy as a steam engine. Walras was a trained engineer in the 19th century so I can excuse him for making this approximation, but I can't excuse anyone still following his course more than a century later.

        • huitzitziltzin 1 hour ago
          I don’t agree that it doesn’t make sense. It’s a good approximation a lot of the time.

          Also: from your comment I’m pretty sure you don’t have the background (correct me if that’s wrong) and so don’t know what it really means in practice to make an equilibrium assumption in a macro model: Markets clear, on average people have reasonable beliefs about the evolution of aggregate variables, firms maximize expected profits. That’s all pretty harmless.

          I definitely don’t agree that we are “using mathematical tools which aren’t suited for that.” We aren’t treating the economy “like a steam engine.” The entire revolution in macro from the 1970’s on involves optimizing agents. There is no useful analogy to a steam engine.

          I suspect you have been reading criticism by people who are misinformed about what macro actually is and how it is practiced.

    • mym1990 23 hours ago
      While your last point is certainly an ideal to aspire to, something tells me that the powers that be would not actually want to get rid of booms and busts, because ultimately that is where a lot of the “wealth” for those high up is created. You don’t really need complex models to solve the problem of some humans being really, really greedy, driving markets to overheat, ending in catastrophic failure.
      • sdwr 10 hours ago
        Booms and busts emerge naturally from market dynamics, even when everyone is acting fairly and reasonably. You don't need to add sneaky, greedy people pulling the strings from behind a curtain.
    • Onavo 1 day ago
      > we do need and should have good fine-grain computational models of complex systems such as the cell .. and the global economy.

      Thanks to the pioneering work done by physicists, we realized we could simulate dimension reduced versions of reality instead. We call them statistics and differential equations :)

      Stack enough of them together, you get something called "deep learning". Large scale national lab supercomputer type numerical simulations are for your grandparents (these days you can probably take shortcuts and simulate that sort of born secret computations in a neural net that is much more compute efficient than the typical supercomputer).

    • jjmarr 1 day ago
      If you had such a model you could arbitrage between Polymarket betting on wars and stock prices. There's not much of an incentive to release such a model publicly.
  • HPsquared 19 hours ago
    Related: MONIAC, a 1949 analogue computer macroeconomics simulator, with water flowing through the machine representing money and spending etc.

    https://en.m.wikipedia.org/wiki/Phillips_Machine

    Short clip: https://youtu.be/beuseJ0Wm3M

    Detailed demo: https://youtu.be/gkNaZJmii28

  • dlojudice 1 day ago
    Agent-based modeling offers a more realistic approach to economic systems than traditional equilibrium models. New approachs including generative agents (ABM+LLMs) are promising. J. Doyne Farmer's recent book "Making Sense of Chaos: A Better Economics for a Better World" is a great reading for those interested in this field.

    https://www.amazon.com/Making-Sense-Chaos-author/dp/02412019...

    • huitzitziltzin 1 day ago
      No. There is no macroeconomist who wouldn’t adopt these approaches if they were “better”.

      Agent based models have been around since the 1980’s at least. No one uses them in central banks, no one uses them in industry, and you can be very confident that they’ve tried.

      • abdullahkhalids 21 hours ago
        Neural network based computer vision models also existed for decades. They weren't very good and weren't really used, till early 2010s when people figured out how to make them work. Now they are vastly superior to all the other ways.

        This is quite common across the sciences. Some technique doesn't seem to work because of missing crucial insights or technology. Then somebody fills the gaps, and the technique works.

        These types of models in economics might or might not become viable at some point.

        • huitzitziltzin 1 hour ago
          There are plenty of people working on the application of ML in economics, including NN methods, and including in macro.

          That’s a totally different class of model to this agent based approach. People in the (small) agent based modeling community have been pushing their stuff for decades to no effect.

          Sure it’s possible that there’s some amazing advance I can’t see coming in the future but as of now I would not recommend anyone pursue ABM.

        • DonaldPShimoda 21 hours ago
          "The models might become viable at some point" is very different from the original claim at the top level of this comment chain, though, which made a positive assertion that agent-based models are better. The parent comment to yours was right to call out that claim, and it offered a reasonable basis for that counterargument at the same time.
          • abdullahkhalids 9 hours ago
            "realistic" is an interesting word, because it can have different connotations.

            We can write a very accurate quantum mechanical model for the oxygen atom. But you can't actually simulate it without a galaxy sized classical computer. But it is very realistic=accurate model.

            Or you can write and easily simulate a non-realistic semiclassical model. This one is a realistic=efficiently simulatable model.

            Obviously a fully agent made model is more realistic in the "accurate" sense, because it correctly models the underlying reality. But if you make realistic agents, you have something inefficient (non realistic in the "simulatable" sense).

      • dlojudice 1 day ago
        • noitpmeder 23 hours ago
          Sure, just don't necessarily sell them as "more realistic" if they're not performing as well in real situations
          • littlestymaar 5 hours ago
            Its not like the classical models are any good in terms for performance in real situations, as they have proven to be unable to predict anything over the past 40 years better than a basic linear extrapolation from the trend would have.

            Current macro-economics models are arguably not much better than a broken clock in terms of predicting power.

      • littlestymaar 5 hours ago
        Right, Agent-based models are only useful as “exploration” tool, you cannot really use them for forecast because there's an impractically high number of parameter to tune.

        Micro-founded macro economics models (say DSGE) are much easier to tune based on available historical data so they are much preferred, and nobody seams to care that they have the same predicting power as astrology.

      • imtringued 19 hours ago
        You're taking this from the perspective of people who are stuck in a specific mental framework who want to prove that their mental framework is the right one, no matter how impossible it is in practice.

        What if you don't care about tuning against a real macro-economy? What if the economy being fictional was the entire point?

        Let's suppose you wanted to make a game that simulates a realistic economy as a gameplay element no different from say a physics engine. Why wouldn't you do it using agent based modeling? What you're saying sounds purely dogmatic now. It's more about thought termination than actually accomplishing something. After all, central banks and businesses don't give a damn that agent X did action Y at time Z for all agents, actions and times. Meanwhile in a game? It's actually essential, because the model is the reality inside that fictional world. The model is "perfect".

    • airstrike 1 day ago
      Thanks for the link. If anyone has additional links, including scholarly references, this is an area of huge interest to me but I wouldn't know where to turn to for the latest research and models.
    • jgord 1 day ago
      stands to reason .. if we assume the actual economy is full of autonomous agents [ people, companies, governments ] acting largely in self interest.
      • jgord 1 day ago
        Demis Hassabis seems to describe a process whereby an AI can accelerate the results of billions of simulations by efficiently encoding that predictive behavior.. making something that is computationally expensive to simulate perhaps several orders of magnitude more tractable.

        This has proven out in the acceleration of actual weather prediction using AI which means it can be feasibly run on a single desktop machine.

        I think its not a stretch to imagine that a) there is a way to simulate the whole economy at the same level of quality as a weather or climate simulation b) AI can accelerate the computations to the point they can run on accessible hardware.

        We need this whole economy simulation ... to answer practical questions such as - if we dole out UBI to everyone to cover basic living costs, will that simply result in the cost of rent going up to absorb the whole amount ?

        • tbrownaw 23 hours ago
          > We need this whole economy simulation ... to answer practical questions such as - if we dole out UBI to everyone to cover basic living costs, will that

          "How will humans (in aggregate) behave under novel conditions?"

          Models tend to behave poorly when asked about things outside their training distribution.

        • LeonB 1 day ago
          > if we dole out UBI to everyone to cover basic living costs, will that simply result in the cost of rent going up to absorb the whole amount?

          For that to be true, rent-seeking would have to literally capture all surplus. In which case UBI wouldn’t be an option in the first place.

          The marginal increase in the purchasing power of someone who went from having $0 to $n would always be greater than the increase in purchasing power for someone who went from $1 billion to $1 billion + n - even with inflation.

    • lamename 1 day ago
      Neat, now I'm curious. Can you explain why?
      • dlojudice 1 day ago
        Agent-based models capture the messy reality of economic systems by simulating heterogeneous actors making local decisions with imperfect information, allowing for emergent phenomena, non-linear dynamics, and adaptation over time, precisely the features that equilibrium models abstract away through unrealistic assumptions of perfect rationality, homogeneity, and static optimization that fail to predict or explain crises, bubbles, and technological disruptions that define actual economic evolution. To be honest, ABMs aren't perfect either. They face challenges with calibration, validation against empirical data, computational limitations, etc.
        • neilwilson 17 hours ago
          Not to mention non-ergodicity, path dependency and hysteresis.
  • vannevar 7 hours ago
    This is not so much a model economy as it is a model market. But still interesting to see the dynamics that emerge from even an algorithmically simple model when you have multiple agents interacting over time.

    For even a simple economy, I think you'd need to simulate money directly, and include the notions of rent and work.

  • strstr 19 hours ago
    The most interesting toy economy I’ve seen has been d2jsp and its “forum gold”. Forum gold is primarily used as a fiat currency for diablo 2 trading. It’s a janky digital currency on a janky forum from like 20ish years ago, that’s still alive today. You can technically buy the currency from the forum, but in practice few do that. Most people just trade items to bootstrap.

    Having futzed with bartering in diablo (and non-fiat trading denominated in items of stable value), I quickly came to appreciate fiat currency. Being able to combine two “half trades” into an equivalent barter exchange is vastly easier.

    At one point I was able to trade some of the forum gold I accumulated from diablo 2 for a “perfect IV foreign Ditto” for shiny pokemon breeding.

  • admiralrohan 21 hours ago
    This is very very interesting.

    Want to hear some of the behind-the-scenes stories. What was the initial scope and how did you break down the whole project? As it's very hard to wrap around the whole thing at once.

  • cookiemonsieur 19 hours ago
    can the economy even be predicted ? Was it ever done to any successful degree in the past ? And if so, to what end ?

    I like the idea conceptually, but it doesn't seem to be good enough to halt economic disasters (or correction as we like to call them nowadays).

  • jszymborski 1 day ago
    I wonder how those plots were made, they're neat. GNUplot?
  • exe34 20 hours ago
    Predicting the weather helps save money for rich people. Predicting the economy might not be as profitable for them if everybody uses it. Booms and busts are a feature, not a bug.
  • DeathArrow 20 hours ago
    Just as in the real world we don't spend most time fighting between each other or some monsters, it would be nice to have a MMO that focuses mostly on economic activities. By that I mean producing goods services and trading.
    • RugnirViking 12 hours ago
      its really hard to make something like that fun. The real world economy is driven on asymmetrical inefficiencies and lack of information, things that wikis and game balance pretty much destroy.

      It's only fun to make money on say world of warcraft because most people aren't also doing that. (but instead buy your goods and use them for something essentially unproductive in economy-terms) Even then it can feel pretty stupid given the amount of arbitrage bots people have set up, you have to focus on very niche opportunities or oversights by those arbitrage bots. Kinda like the real economy

    • tekla 12 hours ago
      Eve Online?
  • cowpig 1 day ago
    Primer is a youtube channel with a fantastic intuitive and gentle introduction to this topic: https://www.youtube.com/watch?v=PNtKXWNKGN8

    This paper from one of the field's pioneers is a nice introductory overview of the space from an academic perspective: https://faculty.sites.iastate.edu/tesfatsi/archive/tesfatsi/...

    • littlestymaar 4 hours ago
      I love Primer, but this particular video has a fatal flaw which makes it converge to the same result as microeconomics: it considers seller's cost to be a marginal cost, which is zero when the rocket hasn't been sold and is paid when the rocket is sold. But that's absolutely not how real world market works, and a multi-agent simulation which has the ability to use different hypothesis (upfront costs) should definitely do so, because then we'd see a completely different result.
  • __loam 1 day ago
    You don't actually have to put a generated image at the top of every blog post guys.