HN.zip

Simulated Economy Tutorial

84 points by jfantl - 38 comments
cookiemonsieur [3 hidden]5 mins 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).

jgord [3 hidden]5 mins 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.

dmbche [3 hidden]5 mins 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.

noosphr [3 hidden]5 mins 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 [3 hidden]5 mins 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 [3 hidden]5 mins ago
That's only for two way relationships, you need N way relationships, which is N^N.
wordpad [3 hidden]5 mins 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 [3 hidden]5 mins 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 [3 hidden]5 mins ago
how many people do you talk to in a day?
onlyrealcuzzo [3 hidden]5 mins 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 [3 hidden]5 mins 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.

huitzitziltzin [3 hidden]5 mins 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.

littlestymaar [3 hidden]5 mins 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.

mym1990 [3 hidden]5 mins 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.
jjmarr [3 hidden]5 mins 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.
Onavo [3 hidden]5 mins 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).

dlojudice [3 hidden]5 mins 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 [3 hidden]5 mins 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 [3 hidden]5 mins 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.

DonaldPShimoda [3 hidden]5 mins 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.
dlojudice [3 hidden]5 mins ago
noitpmeder [3 hidden]5 mins ago
Sure, just don't necessarily sell them as "more realistic" if they're not performing as well in real situations
imtringued [3 hidden]5 mins 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 [3 hidden]5 mins 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.
lamename [3 hidden]5 mins ago
Neat, now I'm curious. Can you explain why?
dlojudice [3 hidden]5 mins 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.
jgord [3 hidden]5 mins ago
stands to reason .. if we assume the actual economy is full of autonomous agents [ people, companies, governments ] acting largely in self interest.
jgord [3 hidden]5 mins 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 ?

LeonB [3 hidden]5 mins 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.

tbrownaw [3 hidden]5 mins 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.

admiralrohan [3 hidden]5 mins 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.

exe34 [3 hidden]5 mins 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 [3 hidden]5 mins 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.
jszymborski [3 hidden]5 mins ago
I wonder how those plots were made, they're neat. GNUplot?
heromal [3 hidden]5 mins ago
nivertech [3 hidden]5 mins ago
Are there similar non-GoLang libs or CLI tools?
cowpig [3 hidden]5 mins 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/...

__loam [3 hidden]5 mins ago
You don't actually have to put a generated image at the top of every blog post guys.