Production functions – so pretty, so unphysical

I’m rediscovering my old frustrations with aggregate production functions like the CES. They’re handy, but I have a nagging suspicion, never quite formalized, that they just don’t capture the engineering/thermodynamic realities of substitution. Anyone know any papers on that? I’m aware of critiques of KLEM applications, but not interfuel aggregation.

prodFimages

Click to enlarge. From a google images search for production function.

Candy Causality Confusion

Candy Professor is confused:

Contagious Cavities

One of the favorite themes of the candy alarmists is dental decay: candy causes cavities! How many times have you heard that one? But it just ain’t so.

From no less an authority than the New York Times, this week’s Science section:

While candy and sugar get all the blame, cavities are caused primarily by bacteria that cling to teeth and feast on particles of food from your last meal.

Your last meal. Did you hear that? Not candy, not at all. It’s food, just plain old food, that those cavity-causing bacteria crave.

This is just what we’d all like to hear – cavities are a random act of bacterial promiscuity, so we can gorge on candy as much as we want without dental repercussions!

Unfortunately, this is highly misleading.

The NYT article mentions that streptococcus mutans is one of the common cavity precursor bacteria. A quick trip to wikipedia and microbe wiki reveals all. Here’s a rough picture of the process:

candy

click to enlarge

At top left, food (including candy) goes in. The output of this system that we’re interested in is healthy tooth enamel – i.e. the opposite of cavities. There are many causal pathways between candy and cavities. The simplest (in red) starts when candy (i.e. sugars) goes into the mouth. There, in the presence of bacteria, it’s metabolized to acid, which is neutralized by eroding enamel. That’s bad.

Things get worse if the candy contains sucrose. Sucrose is enzymatically degraded to fructose and glucose (green path), directly fueling the acid process. More importantly, S. mutans preferentially hijacks sucrose, consuming the fructose for energy and using the glucose to make a sticky polysacharide scaffolding for its colonies, which we come to know as plaque. That plaque becomes a home for other less hardy bacteria (orange path). The existence of food and housing allows bacterial populations of all sorts to flourish (blue paths). All of this increases enamel-eroding acid metabolism.

Admittedly, none of this would happen without bacteria around to metabolize sugars. But that’s a feedback loop – sugar intake fuels the growth of the bacterial populations. The idea that “It’s food, just plain old food, that those cavity-causing bacteria crave” is surely nonsense, because there’s a metabolic penalty and a delay in converting complex carbohydrates into cavity-causing sugars. That delay means that the shorter time constant, of chewing and swallowing your food, dominates, so that the primary fuel for bacteria must be simpler (or stickier) carbohydrates.

The existence of at least half a dozen causal pathways from candy intake to loss of tooth enamel gives the lie to the notion that it’s “Not candy, not at all.” You can blame the bacteria if you like, but that’s a victim’s approach to policy. Absent an S. mutans vaccine or similar innovations, there’s not much we can do about our resident bacteria. We can, however, choose not to feed them substances that are uniquely suited to fueling their populations and the destructive processes that result.

Theil Statistics

Source: Created by Rogelio Oliva, 1995; Updated by Tom Fiddaman, 2009 2011 – slight improvement to numerical robustness.

See Sterman, J. D. 1984. Appropriate Summary Statistics for Evaluating the Historical Fit of System Dynamics Models. Dynamica 10 (2): 51-66.

Units balance: Yes

Format: Vensim; requires an advanced version

Files:

D-4584 Theil Statistics documentation– D-memo documentation

Theil_2011.mdl – Theil Statistics model

Theil_2011.vpm – published binary version; includes data.vdf so it’ll run right out of the box

Dummy_data.mdl – dummy data generator creating input to Theil model

April Fools in the MT Legislature

I was planning an April Fool’s Day post to mock the Montana legislature, but I really can’t top what’s actually been going on in Helena over the past few days. One bar-owning legislator proposed rolling back DUI laws, to preserve the sacred small town rite of driving home drunk from the bar. The same day, they seriously debated putting the state on the gold standard, which drew open laughter and an amendment to permit paying state transactions in coal. The gold bugs, who fancy themselves constitutional scholars, evidently weren’t around when the proposal to assert eminent domain power over federal lands was drafted. I could go on and on… It’s troubling, because I keep getting my news reader feed mixed up with The Onion.

A comment at the Bozeman Daily Chronicle captured widespread sentiment around here better than I can:

Hey members of the house- Thanks for wasting our money. Try to do something productive up there instead of making all Montanans look like a bunch of idiots. If I was as worthless as you I’d kick my own a_$. Put that in your cowboy code…

Dynamics of Fukushima Radiation

I like maps, but I love time series.

ScienceInsider has a nice roundup of radiation maps. I visited a few, and found current readings, but got curious about the dynamics, which were not evident.

So, I grabbed Marian Steinbach’s scraped data and filtered it to a manageable size. Here’s what I got for the 9 radiation measurement stations in Ibaraki prefecture, where the Fukushima-Daiichi reactors are located:

IbarakiStationRadiation

The time series above (click it to enlarge) shows about 10 days of background readings, pre-quake, followed by some intense spikes of radiation, with periods of what looks like classic exponential decay behavior. “Intense” is relative, because fortunately those numbers are in nanoGrays, which are small.

The cumulative dose at these sites is not yet high, but climbing:

IbarakiStationCumDose

The Fukushima contribution to cumulative dose is about .15 milliGrays – according to this chart, roughly a chest x-ray. Of course, if you extrapolate to long exposure from living there, that’s not good, but fortunately the decay process is also underway.

The interesting thing about the decay process is that it shows signs of having multiple time constants. That’s exactly what you’d expect, given that there’s a mix of isotopes with different half lives and a mix of processes (radioactive decay and physical transport of deposited material through the environment).

IbarakiRadHalfLife

The linear increases in the time constant during the long, smooth periods of decay presumably arise as fast processes play themselves out, leaving the longer time constants to dominate. For example, if you have a patch of soil with cesium and iodine in it, the iodine – half life 8 days – will be 95% gone in a little over a month, leaving the cesium – half life 30 years – to dominate the local radiation, with a vastly slower rate of decay.

Since the longer-lived isotopes will dominate the future around the plant, the key question then is what the environmental transport processes do with the stuff.

Update: Here’s the Steinbach data, aggregated to hourly (from 10min) frequency, with -888 and -888 entries removed, and trimmed in latitude range. Station_data Query hourly (.zip)

The Secret of the Universe in 6 sentences

Niall Palfreyman wrote this on the board to introduce a course in differential equations:

  1. The Secret of the Universe in 6 sentences
  2. Nature always integrates flows over time
  3. Flows always differentiate fields over space
  4. Structure determines behaviour
  5. Algebra is the study of structure
  6. Dynamics is the study of behaviour

I like it.

A little explanation is in order. I have my morning coffee in hand. It’s warmer than the room, so it’s cooling off. It’s heat winds up in the room. If I want to manage my coffee well, neither burning my tongue nor gagging down cold sludge, I need to be able to make some predictions about the future behavior of my cuppa joe. I won’t get far by postulating demons randomly stealing calorics from my cup, though that might provide a soothingly fatalistic outlook. I’m much better off if I understand how and why coffee cools.

#2, the “nature integrates flows” part of the system looks like this:

coffeeCooling

Each box represents an accumulation of heat (that’s the integral). Each pipe represents a flow of heat from one place to another. The heat currently in the house is simply the net result of all the inflows from coffee cups, and all the losses to the outside world, over all time (of course, there are other flows to consider, like my computers warming the room, and losses to the snowy outside).

In the same way, the number of people in a room is the net accumulation of all the people who ever entered, less all those who ever left. A neat thing about this is that the current heat in the cup, or count of people in a room, is a complete description of the state of the system. You don’t need to know the detailed history of inflows and outflows, because you can simply take the temperature of the cup or count the people in the room to measure the accumulated effects of all the past events.

The next question is, why does the heat flow? That’s what #3 is about. Heat follows temperature gradients, as water flows downhill. Here’s a temperature field for a coffee cup:

Coffee_applepie_infrared

wikimedia commons

Heat will flow from the hot (red) cup into the cool (green) environment. The flow will be fastest where the gradient is steepest – i.e. where there’s the greatest temperature difference over a unit of space. That’s the “flows differentiate fields” part. Other properties also matter, like the thermal conductivity of the cup, air currents in the room, insulation in the wall, and heat capacity of coffee, and these can also be described as distributions over space or fields. That adds the blue to the model above:

CoffeeStructure

The blue arrows describe why the flows flow. These are algebraic expressions, like Heat Transfer from Cup to Room = Cup to Room Gradient/Cup-Room Heat Transfer Coefficient. They describe the structure – the “why” – of the system (#5).

The behavior of the system, i.e. how fast my coffee cools, is determined by the structure described above (#4). If you change the structure, by using an insulated mug to change the cup-room heat transfer coefficient for example, you change the behavior – the coffee cools more slowly.* The search for understanding about coffee cups, nuclear reactors, and climate is essentially an effort to identify structures that explain the dynamics or patterns of behavior that we observe in the world.

* Update: added a sentence for clarification, and corrected numbering.

Then & Now

Time has an interesting article on the climate policy positions of the GOP front runners. It’s amazing how far we’ve backed away from regulating greenhouse emissions:

Then Now
Pawlenty signed the Next Generation Energy Act of 2007 in Minnesota, which called for a plan to “recommend how the state could adopt a regulatory system that imposes a cap on the aggregate air pollutant emissions of a group of sources.” The current Tim Pawlenty line on carbon is that “cap and trade would be a disaster.”
Here he is in Iowa in 2007, voicing concern about man-made global warming while supporting more government subsidies for new energy sources, new efficiency standards, and a new global carbon treaty. Mitt Romney regularly attacks Barack Obama for pushing a cap and trade system through Congress.

And so on…

I can’t say that I’ve ever been much of a cap and trade fan, and I’d lay a little of the blame for our current sorry state at the door of cap and trade supporters who were willing to ignore what a bloated beast the bills had become. Not much, though. Most of the blame falls to the anti-science and let’s pretend externalities don’t exist crowds, who wouldn’t give a carbon tax the time of day either.

Vensim Compiled Simulation on the Mac

Speed freaks on Windows have long had access to 2 to 5x speed improvements from compiled simulations. Now that’s available on the Mac in the latest Vensim release.

Here’s how to do it, in three easy steps:

  • Get a Mac.
  • Get the gcc compiler. The only way I know to get this is to sign up as an Apple Developer (free) and download Xcode (I grabbed 3.2.2, which is much smaller than the 3.2.6+iOS SDK, but version shouldn’t matter much). There may be other ways, but this was easy.
  • Get Vensim DSS. After you install (checking the Install external function and compiled simulation support to: box), launch the program and go to Vensim DSS>Preferences…>Startup and set the Compiled simulation path to /Users/Shared/Vensim/comp. Now move to the advanced tab and set the compilation options to Query or Compile (you may want to skip this for normal Simulation, and just do it for Optimization and Sensitivity, where speed really counts).

OK, so I cheated a little on the step count, but it really is pretty easy. It’s worth it, too: I can run World3 1000 times in about 8 seconds interpreted; compiled gets that down to about 2.

Update: It turns out that an installer bug prevents 5.10d on the Mac from installing a needed file; you can get it here.

Vensim->Forio Simulate webinar tomorrow

Tomorrow I’ll be co-hosting a free webinar on development of web simulations using Vensim and Forio. Here’s the invite:

VENSIM/FORIO WEBINAR: How to create web simulations with Vensim using Forio Simulate

Vensim is ideally suited for creating sophisticated system dynamics simulation models, and Ventana UK’s Sable tool provides desktop deployment, but how can modelers make the insights from models accessible via the web?

Forio Simulate is a web hosting application that makes it easy for modelers to integrate Vensim models into end-user web applications. It allows modelers working in Vensim to publish VMF files to a server-based installation of Vensim hosted by Forio. Modelers can then use the interface design tool to create a web interface using a drag-and-drop application. No programming is necessary.

Date:
Wednesday, March 23rd @ 1 PM Eastern / 10 AM Pacific

Presenters:
Tom Fiddaman from Ventana Systems, Inc.
Billy Schoenberg from Forio Online Simulations

Cost:
Free

In this free webinar, Tom Fiddaman and Billy Schoenberg will show how Vensim modelers can combine interactive web applications with Vensim.

The webinar will cover:

1. Importing your Vensim model into Forio Simulate for use on the web.
2. Exploring your model with the Forio Simulate Model Explorer
3. Creating a web based user interface without writing code
4. Expanding past the drag and drop UI designer using Forio Simulate’s RESTful APIs

This webinar is suitable for all system dynamics modelers who would like to integrate their simulation into a web application.

There is no charge to attend the webinar. Reserve your spot now at https://www2.gotomeeting.com/register/474057034