Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Thursday, February 27, 2014

Measuring Supply and Demand in a Simulated Economy

Isn't Equilibrium Where Supply Equals Demand?

I was on vacation last week (which is why I haven't posted in a while) and spent some time thinking about where I want to go with the blog. I realized that it would probably be best to focus on basic principles before trying to get too creative with things like variations on the bargaining model. Besides, we can get a lot more mileage out of these key ideas.

So, what's all this talk about competitive equilibrium being the allocation where agents' marginal rates of substitution are equal to each other and their utility curves are tangent? Isn't it a lot easier to just say that equilibrium is where supply equals demand? Well, yes, it is, and actually, that is how we found the competitive equilibrium; we just approached it from another perspective. Recall that we did calculate the agents' demand curves along the way. As we'll see below, we actually found the supply curves as well, even if that isn't obvious right now.

Wednesday, February 12, 2014

Bargaining Power in a Simulated Barter Economy

What about non-competitive equilibria?

In my last post, I went through the process used to derive the competitive equilibrium allocation that I plugged into the trade function in our economic simulator. It wasn't just some arbitrary trade rule; I derived it from the agents' utility functions, making sure to meet certain conditions to define a competitive equilibrium. 

To reach a competitive equilibrium, we must assume that both agents are price takers. That is, they don't set the terms of their trade; the market does, and they just trade according to the market price. In a competitive market, the equilibrium price is the one that satisfies the demand functions of all the agents, even when there are only two of them.

But what if we relax those assumptions? Our model is still using a barter economy, after all, and some people are better negotiators than others. So let's consider trades where the outcome will still be on the contract curve (i.e., the outcome will still be an equilibrium; i.e., there will be no more ways to trade without making someone worse off). But now let's look at what happens when one agent is able to negotiate a better price. The weaker negotiator will still benefit from trade, but not as much as they did in a competitive equilibrium.

Wednesday, January 29, 2014

Peter Norvig's Economic Simulator

Let's build an economy!

I've wanted to do this blog for a while, but I had no idea where to begin.  So I want to thank Peter Norvig for giving me the entry point I was looking for.

Peter Norvig is an artificial intelligence super guru, and a director of research at Google.  He's a very bright guy. Last week he posted an entry on his blog about how to program an economic simulator in Python. This is something I've wanted to do for quite some time, so I was very interested to see how he put it together.  I would recommend you at least skim through his blog post before reading on, if you're interested in understanding how the simulation works.  In his words:
This is a simulation of an economic marketplace in which there is a population of actors, each of which has a level of wealth (a single number) that changes over time. On each time step two agents (chosen by an interaction rule) interact with each other and exchange wealth (according to a transaction rule). The idea is to understand the evolution of the population's wealth over time.
The simulator has four components.  There's a population of people with randomly distributed wealth. There's an interaction model that matches people in the population to trade with each other.  There's a transaction model that determines who gets what when they trade.  And there's a simulation model that ties it all together by creating a population, randomly choosing which people interact, executing their transactions, and reporting on the simulation results.  (In this case, the results are measurements of how the wealth is distributed among the members of the population.)