Monday, May 25, 2009

Is Apple taxing developers?

They say controversy sells, so I'm going to leap right in to the fray. When I saw the new MS adds, a few thoughts sprang to mind a) they must be getting desperate, b) bring out the tea-bags and c) "these things are like so rigged, mom". But then my MacBook Pro finally died. It was the original Intel machine at 1.83 Ghz and has served me well through the last few years. I'm not sure that its worth it to repair it now and I need a faster machine for on the road demos anyway. But I am really not wanting to spend 2.5k+ on a new laptop right now. I just bought a sweet Mac Pro and that's perfect for my real software development work. So I thought; hey keep an open mind and take a look at some Windows machines.

Now, to forestall all of the Mac bigots out there, don't bother. I'm one too. You'd have to drag me kicking and screaming to use a Windows machine as my daily driver. But I like to find out the true cost of what I'm buying and I was intrigued by rogerv's thoughtful response to my last blog entry. So in the end, Apple's indifferent support for Java was just the push I needed to at least take a look at what I could get for my money. I've now spent a few hours of my life -- hours I'll never get back -- wading through a bunch of ugly, hucksteristic PC vendor websites collecting this data. You owe me bigtime, because now you don't have to. If you're looking for a decent on-the-road development machine, this is I think a pretty good sampling. These all have 4GB RAM and have generally the same features except where noted.






ModelProcessorHDDimsScreenGraphicsOpticalPrice
ASUS L502.53 6MB L2320GB 5400 rpm14.76x10.4x1.61440x9009400M GT 1GBDVD RW$1299
Sony Vaio FW2.66 6MB L2320GB 7200 rpm15.1x10.3x1.461600x9003650 512MDVD RW$1329
Lenova ThinkPad T5002.80 6MB L2250GB 7200rpm14.1x10.0x1.31680×1050 CCFL3650 256MBDVD RW$1453
ASUS G2.66 6MB L2640GB 720014.76x10.4x1.61680x10509800M GSDVD RW$1699
Dell Crapola 15302.60 6MB L2500GB 5400rpm14.06x10.3x1.381440x900 LED8600M 256MBluray$1979
MacBook Pro2.66 6MB L2250 GB 7200rpm14.35x9.82x.951440x900 LED 9400M GT 512M + 9400MDVD RW$2474


Damn it. Just what I didn't want to know. Question.. am I really going to fork out an extra $1k for really good industrial design, firewire, and a real Operating System? Especially for a machine that I'll be using to check email at home and support demos?

BTW, the only thing that would even make me consider a move is that I've just installed the Windows 7 beta, and it doesn't suck so bad. If my only choice was Vista, I wouldn't even consider going with a PC. But as I mentioned in comments on the last post, the one thing that would be the hardest to give up is KeyNote.

I think developers are the ultimate hardware bell-weathers. We know the technology, we know what matters and what doesn't, and we're often the first person that other folks consult when they are about to buy a new machine. I was pretty sure that Microsoft was in trouble three years ago when Apple started delivering Intel machines. But I knew they were in trouble when my developer friends also began buying MacBooks. Are we about to witness a reverse of this trend?

I actually don't think these price disparities are typical -- in fact, these sorts of claims never got through my BS filter before; they just didn't stand up to close scrutiny. But now.. PC vendors are in the midst of a price war, component costs are way down as Asian component vendors try to survive on volume and Apple simply hasn't kept up. Instead they're coasting and looking gleefully at the insane margins they'll be racking up over the next couple of quarters. And even though the new add campaigns are stupid and hard to watch, for once Microsoft has a crucial factor on its side: the truth, or a reasonable facsimile at least. But it takes a long time to turn perceptions around and by the time people really begin to do their homework and Apple responds with better prices, the "Apple tax" meme will be burned in. Please Apple, get your prices in line, and do it soon.

Update: One of the ironies here is that Apple seems to to really be sticking it to the high-end users, when the difference on the lower end really isn't that bad. For example, I was able to spec out a Sony Vaio SR machine to the same specs as the 2.4 Ghz MacBook for $1229. That's compared to $1699 or the MacBook w/ 4GB RAM. A 38% premium isn't great but its a lot better than 92% more for the MacBook Pro! I could see grimacing and paying $450 more for OS X, that cool unibody case, keys where they are supposed to be and so on, and in fact if push comes to shove that's probably what I'll do. The new MacBook integrated graphics look reasonably decent and I like the smaller size, but I wouldn't look forward to running Eclipse on the 1280 x 800 screen. On the other hand, I came across the Vaio Z-series -- that one looks pretty sweet..I'm digging the 1600x900 display. But wait, it costs $1869! Hey, maybe that's the lesson from all of this. You want quality, elegance, and functionality you're going to pay for it one way or another...

Update 2: The other thing I learned is that Dells are really over-priced. An XPS similar to the MacBook came in at $1988. So maybe we should be talking about the Dell tax. It doesn't matter because after my experience with the Dell laptop that my old company assigned me I'm never buying another one again.

Wednesday, May 20, 2009

Does Apple hate Java?

Apple seems to have a thing about Java. On the one hand they make a play as big supporters but on the other they have been doing a -- let's face it -- lousy job of maintaining even a baseline level of actual support for it. At some point doesn't this reach beyond technical mishaps and enter the area of willful neglect?

  • I've already mentioned that Apple 2D graphics are badly broken out of the box.

  • And OS X is now the only major OS that can't run Eclipse under 1.6 out of the box. This used to be due to Eclipse's reliance on the Carbon UI, but now that the Eclipse Cocoa team has a very nice SWT build that excuse has gone away. I'd really like to use the 1.6 64-bit vm for development, but it is difficult to impossible to get it running consistently because of the infamous compiler bug.

  • And now, Ars has word that a critical security bug still hasn't been patched. Security experts recommend that we don't use Java in web-browsers at all.


We're stuck with 1.6.0.7 when everyone else is at 1.6.0.13! What gives, Apple? Is this a lack of resources, weaknesses in the Apple development team or some kind of nefarious scheme to make everyone abandon Java in favor of Objective C? OK, the last is silly and paranoid, but it does make you wonder...

Update: I should mention that there is a pretty simple way to get Eclipse Cocoa running under Java 1.6 but it's given mixed results. Here's how:
  1. Right-click on Eclipse app and choose show package contents.
  2. Open Contents/MacOS/eclipse.ini
  3. Add the following line at the top:
    -vm /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin
  4. And these lines at the bottom:
    -XX:CompileCommand=exclude,org/eclipse/core/internal/dtree/DataTreeNode,forwardDeltaWith
    -XX:CompileCommand=exclude,org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding,<init>
    -XX:CompileCommand=exclude,org/eclipse/jdt/internal/compiler/lookup/ParameterizedMethodBinding,<init>

Friday, May 8, 2009

Running an Agent-Based Model for Influenza

Introduction


In the last two articles I first explained the design of a simple agent-based model of influenza, and then detailed some experiments I ran on it. Now it's your turn.

The Flu Model Live



Update: Due to one of the many applet deployment gotchas, some users weren't able to see the applet. It should be working for everyone now. Please let me know if it doesn't.--Miles (May 19)

I developed this model using MetaABM (soon to be Eclipse AMF), an agent-based modeling tool that allows users to design models using a graphical editor. MetaABM then automatically generates Java code for Ascape. I've just updated the applet viewer for Ascape so you can run any Ascape model on a webpage without any code modification. (For any Ascape users out there, I'll post an update with this included soon. Or grab the latest from SVN.) I hope the interface is pretty straightforward, but see the help section below for more info.




Help


Interface


This is what the buttons do:
  • Starts the model, or if the model is already running, restarts it to time 0.

  • Pauses or resumes the model.

  • Steps the model forward one period.

  • Stops the model.

  • Displays or hides model settings. These appear on the right side of the applet.

You can change the relative size of the agent and chart view by dragging the splitter between the two panels.

Parameters


You can change any of the model parameters in the settings dialog. Some of them are only used when the model starts up so to see any effect -- those you'll need to restart the model. For example, changes to Min and Max Contact Probability do not have any effect during a model run, but changes to movement probability do. The settings are explained below. (This documentation is also produced automatically by MetaABM.

NameTypeDefault Value
Individual CountInteger250
The number of individuals to create.
Initial Infection ProbabilityReal.05
The probability that any given individual will be infected at the beginning of the model run. For example, if this value is .15, and their are 100 individuals in the model, roughly 15 of those individuals will be infected at time 0.
Min Contact Transmission ProbabilityReal.08
The minimum probability that proximity to a single neighbor for a single period will result in transmission of infection. At the start of each model run, each individual is assigned a contact transmission probability between the minimum and maximum value. For example, if this value was .08 and the maximum value was 0.12 a given individual could have any value between those two, but the average transmission probability would be around .1. If minium and maximum values are the same, then all individuals will have the same chance of passing along infection to a given neighbor. This value must be between 0.0 and 1.0 and less than or equal to Max Contact transmission Probability.
Max Contact Transmission ProbabilityReal.16
The maximum probability that proximity to a single neighbor for a single period will result in transmission of infection. See Min Contact Probability for more information. Must be a value between 0.0 and 1.0 and greater or equal to Min Contact Transmission Probability.
Case Mortality RateReal.05
The current probability that death will occur for a given individual as a result of infection. Some number between 0.0 and 1.0.
Periods per DayInteger24
Min Period ExposureInteger15
The minimum amount of time from initial exposure to infectious asymptomatic or symptomatic state. 0 or greater.
Max Period ExposureInteger24
Maximum time from initial exposure to infectious asymptomatic or symptomatic state. 0 or greater.
Min Period Asymptom InfectionInteger24
Maximum time spent infected without showing symptoms. 0 or greater.
Max Period Asymptom InfectionInteger48
Maximum time spent infected without showing symptoms. May be zero!
Min Period Symptom InfectionInteger24
Minimum time spent infected with obvious symptoms. 0 or greater.
Max Period Symptom InfectionInteger168
Maximum time spent infected with obvious symptoms. 1 or greater.
Movement ProbabilityReal.5
The chance that an agent will move within a given period. May be any value between 0.0 and 1.0.


Rules


By clicking on the Rules tab of the settings dialog, you can play around with how the model executes. For example, you could turn off transmission for some time and see what effect that has on on the overall outcome.

Have Fun



I won't make any suggestions about how to proceed except that you might try some of the things that I discussed in the earlier posts and see what you discover. A couple of requests. It would be great if people could share their experiences with the model. And share the link with you friends!

Tuesday, May 5, 2009

Experimenting with An Agent-Based Model for Influenza

Introduction


In the previous article I introduced an agent-based model of influenza A (H1N1) aka "Swine Flu", and shared some simple exploratory runs. In this next piece, I'll be sharing some thoughts about how we perform basic experiments with ABMs. Then.. you can check out a running version of the model online and play with parameters yourself!

A Quick Quiz


Question


Sorry, but did you expect to get out of here without doing some work? Take a look at the following chart -- it displays the overall number of individuals who are symptomatic infectious for seven different model runs. Referring to the runs we explored in the previous article, what can you say about each of the runs and the parameters they used? Looking at the red and gray runs, which parameters might be similar and which different? The answers are below, don't peek!








...


Answer


Nothing is different. All of these model runs were produced with the same set of parameters. I used the same setup as in the final model of the last article, except for one change -- agents are now assigned an individual contact probability which can vary from 0.08 to 0.16. More on why this is an interesting and useful thing to do in a later article. But the important point is that the only difference between these models is that different random series of numbers were used.

I hate trick questions too, but hey, it's in service of an important point. What if we made recommendations for hospital equipment needs based on the green curves, without running enough models to see the red curves? Not good. And in effect isn't this also what we are do when we use real-world data from a few events to make predictions about future needs? Even when none of the key factors change, we can see very significant changes from one model to another. This is another signal feature of ABMs called "path dependency" -- but we don't really have time to get into that now.. The point is that it isn't generally a very good idea to come up with conclusions based on results from a few runs.

Batch Runs


A lot can be learned just noodling around with an Agent-Based Model. In fact, that's usually where we make the most interesting discoveries. That's the "interactive" side of ABM and it can be really compelling, even addictive. But the "batch" side of the model exploration process is really the most important. Without systematically studying the behavior of the model, you really can't have any confidence that your model results are anything more than flukes or artifacts. A modeling artifact is some phenomenon that seems to be a feature of the domain system we're studying but turns out to be a consequence of the way we've chosen to implement the model. I can't think of a really good example right now, but suffice it to say that they usually involve the coolest, most interesting, mind-blowing behavior. We'll be looking at a model and have a eureka moment ( "I'm going to get an article in Nature!") only to discover that the behavior only exists under a particular set of conditions ("Whoops, never mind..")

More often though, we'll observe differences between different model parameter settings based on a few model runs, but when we do more runs those differences just turn out not to be not that significant. To examine our models in depth we run formal experiments just as one might do in a physics or biology lab. This is something that the social sciences have never been able to do before, and a real benefit of ABM. You certainly couldn't give a bunch of people a deadly virus, restrict their movement and prevent contact with the outside world for weeks on end! Our tests involve multiple runs of our models under different parameters, spatial structures, behavior variations and so on. Typically, we'll do parameter sweeps, which involve taking a few model parameters, changing them systematically and running the model many times for each unique set of parameters. We'll go through a few of these to give you a sense for how it works. Have your snooze alarm handy?

Maximum Health Care Burden


So given the rather wild differences between the model runs above, how can we know that the results from our interactive runs weren't simply a fluke? Again, we need to do a boat load of runs and test our hypothesis against different conditions. Ah, basic science -- and so very different form the way that social science is typically done! The first thing we'll do is look at the effect of our interventions on the maximum number of people infected symptomatically at any given time. Even if we can't keep people from getting sick, perhaps we can do something to lower the maximum burden on the system. So first, we'll vary the probability of movement from 0.0 to 1.0 in increments 0f 0.05, with 21 runs for each probability setting. In this chart, we'll see the average maximum value (got that?) in dark red, and the minimum and maximum ranges for the maximum infection rate in light red.

Well, its pretty clear from that that lowering movement generally reduces the maximum level of health care resources we'll need. But the key word here is "generally". From run to run it would be somewhat questionable to make a policy choice between say a movement restriction of .4 and one of .8; the ranges have very significant overlap. Do we really want to plan for 100 patients say, given that a completely random sets of circumstances could cause those numbers to rise substantially higher? Next, let's look at the effect of contact transmission probability. We've seen that this also seems to make a difference.

Here at least the variation in ranges seems a bit more predictable. (Part of that might be due to the fact that we are using a constant rate of transmission probability for everyone but that's too much to go into now. At some point we really need to be comparing movement rate and the heterogeneity of contact transmission probability. Starting to sound like a paper title here -- a very boring paper title).

Overall Health Effects


As a final example let's look at a somewhat different policy goal. What we can do to control the overall number of infections? Suppose we have two policy levers, one to control movement and the other to control the probability of transmission. Which one to pull?

Just as before, the answer is both. Imagine that there is some kind of increasing cost for either intervention: It's super easy to get people to not go to football games, but really really hard to keep them from visiting their close friends and family. Similarly, though it would be nice to be able to lower transmission as much as possible, you can get people to wash their hands after using the bathroom, but not to do a surgical scrub every time they shake someone else's hand. So there has to be a sweet spot in there somewhere; a place in policy space where a given set of interventions combine to do the most good. This is exactly the kind of balancing act that makes risk management so challenging and the ABM approach so potentially useful.

Conclusion


I hope all of the charts aren't a major bore after the snazzy quicktime movies in the last article. Yes, there is not as much eye candy in this mode of modeling, and it can involve its share of drudgery, but doing rigorous parameter exploration always seems to turn up new areas for exploration and provides a healthy does of negative results. This then gives us the confidence to turn potential insights into real recommendations. You can now run a live version of the model and do your own interactive experiments. And the actual model is at http://metaabm.org/downloads/models/Epidemic.metaabm -- so if you're feeling ambitious you can run your own batch and experiments as well.

Friday, May 1, 2009

An Agent-Based Model for Influenza A (H1N1)

“So the final lesson of 1918, a simple one yet the one most difficult to execute, is that those who occupy positions of authority must lessen the panic that can alienate the members of a society. A society that takes as its motto, "every man for himself" is no longer a civilized society. Those in authority must retain the public's trust. The way to do that is to distort nothing, to put the best face on nothing, to try to manipulate no one. Lincoln said that first and best. A leader must make whatever horror exists concrete. Only then will people be able to break it apart.”
--John Grady, The Great Influenza

Introduction


Update: In this article I go over the basic design of an ABM for flu. In the next article I discuss some experiments I ran on the model. And now you can actually run the model.
  • How does an epidemic like the new H1N1 strain spread?
  • What factors turn an epidemic into a pandemic?
  • Why doesn't everyone get it?
  • Can hand-washing and face-masks really prevent the spread of disease or do they just slow it down?
  • Why are some communities devastated and others emerge almost unscathed?

Over the last weekend as news about the new Influenza A H1N1 virus spread I went into personal crisis management mode, i.e. stressed out. An influenza that primarily kills healthy younger people is troubling and the early reported death rates seemed to confirm that we were faced with a flu that was both virulent and that our immune systems aren't experienced with. I've built Agent-based models of pathogen epidemics and so have some sense of the dynamics involved. And a few years back I'd read John Barry's brilliant book and come away from that with a greater sense of the uniquely challenging aspects of influenza and how political failures in the face of pandemic disease can cost countless lives and plunge whole societies into terror and dysfunction. (By the way, it turns out the George Bush actually did read a few worthwhile things in office.) This new strain looked like the one that people have been worrying about. But sitting around feeling vaguely uneasy isn't very satisfying. So, I thought that it might be helpful and interesting to build an ABM model and share it with people. Agent-based modeling is a great tool for helping people to understand complex phenomenon -- and influenza is a very complex phenomenon.

An important caveat: This isn't a perfect model, and I'm not an expert in epidemiology. So as in everything, question assumptions, trust your own critical judgement, and find primary sources. On the other hand, people make policy and personal decisions based on far worse models than this. And, as my friend and mentor Joshua Epstein has often pointed out, we all have models, but unfortunately most of the time they are implicit -- full of hidden assumptions and inconsistencies. So while this model isn't perfect, it is better than one based on paranoia, anecdote or broad generalization. Because Agent-Based Models (ABMs) map directly to a mental model of how the various parts fit together but add rigor, transparency and the ability to test hypothesis, people who aren't experts in esoteric math can understand and trust them. And because they work over space and time, we get to see the dynamics; how a disease spreads, not just what a given end-state looks like.

While we're talking about Swine Flu because of current concerns, this is actually a quite general model that applies to many different kinds of pathogens. Joshua Epstein, Derek Cummings, Shubha Chakravarty, Ramesh Singha and Donald Burke developed and researched the first ABM models of pathogens, and this model draws on that effort. You can read about the small pox model alone in Toward a Containment Strategy for Smallpox Bioterror: An Individual-Based Computational Approach, but I'd recommend Chapter 12 in Josh's Generative Social Science as it goes into great detail about the overall context, and the other chapters will give you a lot more to chew on. In all of the model runs below, we've made no attempt to calibrate the model to an actual disease, so while it fits qualitative influneza dynamics well, don't expect it to match quantitative results.

While I've addressed prior work that I'm aware of there may be important pieces I've missed. If I've omitted an attribution please let me know. Similarly, any errors are my own and should not reflect on the work of others that I mention here.

A Traditional Model


http://en.wikipedia.org/wiki/File:Sirsys-p9.pngThe classic model for epidemics is the compartment model. The basic idea is to create a set of variables representing the number of people in different disease related categories. In the simplest "SIR" model we have a variable each for the number of individuals who are Susceptible, Infectious, and Recovered. A set of equations represent the rate at which these numbers change over time. When you make some (not-insignificant) assumptions and work these equations out, you get the basic outcome on the right. The green curve represents the number of people infected at any given time. (Unfortunatly, the graphic I found for this doesn't match up with the colors we use later in the model.) Over time, as people move from susceptible and then recover we get two classic "S-curves" as the population as a whole moves out of the susceptible state and later into the recovered state. This kind of curve is found throughout natural and social systems. For example, sales of a new category of products (VHS machines being the classic example) often look like the red curve. In the case of contagions, the rate of new infection moves quite slowly at first, accelerates steeply as more infected people create even more infections, and then falls off as the number of people infected reaches a kind of saturation level.

In this context I can't help but point out how a perfect example of how the public's lack of basic science literacy can be further confounded by news accounts that don't take the responsibility to put raw numbers into context. The NY Times generally has excellent science coverage, but reported the following reassurance on Thursday: "Some experts are cautiously optimistic. A computer simulation of this outbreak released Wednesday by a team from Northwestern University projected a worst-case scenario, meaning no measures have been taken to combat the spread. It predicted a mere 1,700 cases in the United States four weeks from now." Take a look at the figure to the right. How reassured would you be if you knew that four weeks was at this point in the disease projection? Actually, we don't know from the story where we are, so the numbers are only meaningful in a narrow context, for example in determining appropriate short-term health care response. They tell us literally nothing about the long-term outlook!Let's build an ABM and see if we can capture that basic behavior. I designed a working version of this model in an hour or two using MetaABM -- a very high-level modeling tool I've been developing over the last few years -- and have been refining it over the last week. Once you design a model in MetaABM using MetaABM's visual tools, that model can be automatically converted into the Java computer language to run on a number of different modeling platforms.

The ABM Model

Attributes


Agent Color KeyOur model has categories, but they are a bit more complicated than the model above -- we've added a disease status for exposed; split infected into two categories, one for those who are symptomatic and one for those who are asymptomatic (it isn't obvious that the person is sick and they are still moving around normally); and we'll keep track of dead agents as well as recovered. But the most important thing about our model -- what makes it an agent-based model -- is that instead of keeping tack of a single population number for each category, we actually create individual objects, each with its own disease state, other characteristics, and most importantly a location in space. As I explain below for each agent we also keep track of the period that disease states occur.

Behaviors

Then we give the agents a set of behaviors; they move around a landscape, they can become infected and move from one disease state to another, and most importantly, they can transfer the disease from one person to another. The basic life cycle of an agent goes like this; underlined values are model parameters that we can change. At the beginning of each model run, for every agent:
  1. Move to a random location in our space.
  2. Draw a random number. If that number is less than the Initial Infection Probability, become exposed.

For each period after for every agent:
  1. Move to a random neighboring space.
  2. Pick a random neighbor and if one exists, make a random draw. If that draw is lower than the Contact Transmission Probability then expose our neighbor to the virus.
  3. If exposed, the agent determines the number of days that it will be in each of the states, based on:
    • Min and Max Period Exposure
    • Min and Max Period Asymptom
    • Min and Max Period Symtom
  4. Go through our disease process:
    1. If exposed and the period of exposure is over, become infected, either asymptomatically, or if the asymptomatic period is zero, symptomatically.
    2. If asymptomatic and that period is over, become symptomatic.
    3. If symptomatic and that period is over, make a random draw. If that number if greater than the Case Mortality Rate, recover, otherwise die.

Model Runs


“The three goals, Dr. Cetron said, can be plotted on the graph of new infections called the epidemic curve. "You want to shift the curve to the right, blunt the peaks and squash the area under them."” - From the NY Times article quoted above.

How might we accomplish that goal? Why would we even want to? Let's explore different parameterizations of our model and see if we can gain any insights from them. Play the Quicktime Movies below to see running versions of the models.

Run I: No Interventions (Base Parameters)

Flu Model I Chart
As we've kept statistics on our model, we can a graph of what has happened over time. Looks familiar! (Again, note that the colors don't match the first chart.) Now, our model is noisier, but that's exactly what we want. "The real world is messier", and though we certainly aren't modeling the real world, we're arguably a lot closer than in the original equation based model. Now it's my chance to be reassuring and point out that this model has not been calibrated against any kind of real world situation. For example, the death rates are very high -- evan at its most virulent, the Spanish Influenza showed "only" half the death rate shown. You might have noticed already something in the Quicktime movie: even in this model of a very rapidly spreading and virulent disease, not everyone got exposed.

Run II: Hygiene (Lower Transmission Probability)

Flu Model II ChartIn the next run, we'll lower the Contact Transmission Probability from .12 to .08, or by 1/3. We could interpret the difference in two ways. Perhaps in this new version of our little agent world, the virus is simply less contagious. Or perhaps our agents have followed everyone's advice and are washing their hands more often. This is an example, folks -- please keep washing your hands, regardless of what this model seems to be saying, ok?

Now, we have to be careful about drawing conclusions by comparing single model runs. In a real experimental effort we'd be doing parametric studies, which just means that we'd be changing the values like transmission probability systematically and doing many (like thousands) of runs to determine what effects these changes have and whether model runs are consistent when given same initial values. (And actually, as we'll discuss in another post, some of the most interesting models are those that aren't consistent from run to run.)

But we can make some observations. And.. hmmm.. nothing much seems to have changed. We're certainly not seeing 1/3 fewer cases! Almost the same number of people became sick and the duration of the epidemic isn't any different. Perhaps the overall exposure is a bit lower but that could be due to random variation in the model. But.. one thing that is somewhat different is the peak number of cases. That could actually be very important. If you only have so many ventilators available, lowering the peak number of cases by 80% could mean the difference between life and death for many more people, not to mention saving hospital personnel from having to make some very difficult choices.

Equations or Agents?


The issue of hospital resources points out another challenge of modeling that is subtle but extremely important. What exactly does a case mortality rate even mean? Casually, people take it to mean “how deadly is the disease”, but it really matches closer with “how many people did the disease kill, given their health status, exposure to previous strains, and availability and quality of care“. Well, is the quality of care some fixed thing? No, it is actually affected by the number of people who are sick. But our model assumes the death rate as in input parameter, and we don't know how many people will die; that's the point of running the model!

This is a real problem with equation-based models like the classic one we've mentioned above. It doesn't have a “closed-form” solution, which is a polite way of saying that they can never really provide a solution for a question such as “how many people might die in this epidemic”? Now, before I get a bunch of hate-mail from every researcher in the world who still owns a jacket with elbow patches, I should clarify that. There are ways to get very very close to a good solution by using some sophisticated tricks (I mean “techniques”) and by making just a few minor assumptions. One of the most common assumptions is that there are an infinite number of individuals. Another, a favorite of economists, is that there is an infinite amount of time. The biggest assumption of all is that everyone is the same. OK, I'm still grossly simplifying -- and I'll probably get some very polite hate-mail anyway -- so let's move on.

What is different about an agent-based model? First, and perhaps most importantly, questions like “how can we know the death rate when we don't know how many hosptital beds we'll have?” are a lot harder to ignore. The very process of exploring the model causes us to ask more and more questions. The model transparency draws us in, rather than forcing us out. Instead of being faced with complex equations (“you wouldn't understand, but trust me on this”) we have a clear set of attributes and behaviors and we can watch those behaviors in action. Does this mean that our models will never suck? Absolutely not, but we have a much better chance of seeing when they do and making them better. In the case we're referring to here, modelers might choose to add a value for hospital care quality to the overall death rate calculation. This value might at first be some measure of total cases against some global resource level. But over time, we could refine it further and create agents that represent hospitals at particular locations and give them a particular number of ventilators along with some way to get more. And so on.

The key point is that while the general public (whatever that means) seem to actually over estimate the quality of expert estimates -- sloppy media interpretation of those estimates only compounding the issue. Not only do experts make (quite understandable) guesses, the theoretical models behind those assumptions are typically quite limited. Even with (or perhaps because of) all sorts of mathematical tricks and assumptions we end up with a model that is very hard to understand and analyze. People spend a lot of time in graduate schools learning how to do this and the models still miss important details. And they always will, because in the real-world where we are in time matters, and individuals are different. We need equation-based and statistical models and all the rest, but we shouldn't rely upon them. Agent-based models give us another way to look at the world that can challenge traditional models and reveal dynamics we might not otherwise have seen.


Run III: Restricted Contact (Lower Movement Probability)

Flu Model III Chart Back to the main point..we really haven't changed the total number of cases at all. What about adding movement restrictions? Let's add a parameter, called Movement Probability. Then we'll modify the movement rule so that every period, agents make a random draw and only move if that draw is less than the probability. We'll set the value to 0.5 to start off. If we run the model we can see the agents do seem a little less active, and we get a curve that is much lower. But so what? Unless our primary concern is emergency services capacity all that we've done is prolong the misery, right? Whereas the unchecked epdemic is pretty much over by period 500, in this model it drags on for another 100 periods or so. This one could actually get us into the land of unintended consequences. For example, researchers seem to agree that a new flu could be much more dangerous if it appeared at the beginning of the regular flu season instead of the end. In that sense, we're lucky that the flu appeared when it did. But if we prolong the period of outbreak, are we increasing the chances that the disease will linger and spread into the next flu season? The Spanish Flu Pandemic followed exactly that pattern.

Run IV: Hygiene and Restricted Contact

Flu Model III Chart
There is an obvious next move here, and that is to combine the two strategies. Let's try to get people to wash their hands and be a little less social. In the face of a crisis, this is exactly the kind of thing that makes everyone scream about useless half-measures. “What difference does it really make? Everyone is going to get it anyway”. But let's run the model and look at the results. Not only have we lowered the peak as before, but we've also actually managed to control the epidemic much more quickly. And something else that's really nice. We have a significant number of people who never acquire the flu at all -- three times fewer than for the run we did on the previous model. This is especially interesting, because the two methods in isolation didn't change that figure at all. (The death rate is better too, but the rates are so small that we can't really draw a solid conclusion from that.) Do two half-measures make a whole measure? (Outside of the realm of music class, that is?) Well, I don't know about you, but I have a pretty healthy level of skepticism when it comes to government pronouncements about my well-being. (Apparently, eggs are good for us again.) And all of this talk about washing hands and avoiding crowds strikes one as exactly the kind of thing someone would say if they were out of any better ideas. But maybe these guys are on to something.. It certainly merits a closer look.

What's next...

Well, as always seems to be the case, the explorations of the model took a lot more time to write up than they did to do. (And I'd still like to edit this all a bit more as I'm sure I've made a mess of one or two things!) But its 3 am and time to pack it in.
So far we've looked at a pretty simple model, and found some interesting -- if not actually earth-shattering -- dynamics. There is a lot more to explore. If you want to try the model out yourself, it's available in the Eclipse AMP project examples. See http://eclipse.org/amp. And please share your insights and questions here.. we can marry our fears and anxieties with a bit of curiousity and perhaps even enjoy ourselves in the process!

Books Mentioned in this Article


Popular Posts

Recent Tweets

    follow me on Twitter