A little more information on this simple simulation is at the
Nowhere Near Ithaca blog.
In addition to becoming more familiar with the d3 library, one of my main goals with this
visualization was to simply get a feel for the
qualitative rhythm of births and deaths in the U.S. There are fancier ways of approaching this simulation; for example, use state/county/demographic-specific rates,
or estimate the cause of death for each occurrence based on available data from the US Census or other mortality tables freely available.
A few tips:
It may take a few seconds for the first simulated birth/death to occur; on average, a birth should occur about every 10 seconds, and a death every 13 seconds, but
the values will be different for each simulation
Mousing over counties will show a popup with some basic info on the county; clicking the county will take you to a google search on the county in a new window
Mousing over a birth/death in the list will cause the associated county to briefly "pop out" on the map;
clicking will take you to a google search on that city or county
The awesome d3 javascript library by Michael Bostock
Some helpful jQuery plugins:
Date Format by Steven Levithan
, jQuery.Color() for animating between colors with jQuery (with an added hook for "background")
The svg map data for US counties from USA Counties.svg on wikipedia (note that
adjustments were made to address a handful of counties, primarily in Alaska, that have changed since this map was released)
The jStat javascript statistical library for the Poisson distribution calculations;
as simple as the Poisson distribution seems to be, I was concerned about accurately calculating the ratios of exponentials and factorials needed for very low probability events, and jStats seems to be using
Stirling's formula,
which gave me some warm fuzzies. In hindsight, such concern is almost certainly unwarranted in this case, however, as λ is
generally at about a relatively steady 0.134 and 0.08 for births and deaths, respectively, when
calculated for each second as is done here.
Statistics on U.S. religious congregations and membership are from:
Clifford Grammich, Kirk Hadaway, Richard Houseal, Dale E. Jones, Alexei Krindatch, Richie Stanley, and Richard H. Taylor. 2012. 2010 U.S. Religion Census:
Religious Congregations & Membership Study. Association of Statisticians of American Religious Bodies
(see here for data file used).
State-level estimates of "unaffiliated" based on the values at http://religions.pewforum.org/maps.
The rest of the population is assumed to be Christian of unknown denomination or unknown based on the
Pew Global Religion Data, which indicates that
78.3% of the U.S. is Christian.
Some of the denomination names are trademarks of the respective institutions, and these names are used here
assuming nominative use. Their inclusion here
does not suggest sponsorship or endorsement by the trademark holder(s).
The general approach in the simulation is as follows:
For a given time interval dt and total US population N (~ 300 million people - this value is updated as the simulation progresses), calculate the expected number of births or deaths in the interval as
λ = (birth or death rate per year per 1000) * (N/1000) * dt
Estimate the number of births or deaths for the interval as a sample from a
Poisson distribution with mean of λ calculated from previous step
For each birth or death obtained this way, determine in which county it occurred by calculating a random number and then choosing the county
based on its fraction of the total population (e.g., if a county has 0.001% of the total population, then there is a 0.001% chance
that this county would be the one where it occurred). Once the county is determined, a similar process is used to determine which city/town
this event occurred in the county (or outside of any city/town in in the county, which can happen)
The "prediction" of religion for an event is based on the values from the 2010 Religion Census,
coupled with state-level values for "unaffiliated" from http://religions.pewforum.org/maps.
The fraction of "unclaimed" (by a congregation) calculated via the method in the 2010 Religion Census is broken down here into separate "Unaffiliated"
and "Unknown" components, first by using the state-level "Unaffiliated" fraction, then assigning the rest to religion "Unknown".
The result is a fraction of the county in one of the religions, "Unaffiliated", or "Unknown", and these are used
to pick a random "religion" from a county. This method might be updated later.