# 2021.01.03 JH # See http://www.medicine.mcgill.ca/epidemiology/hanley/BridgeOfLife/ # This R function replaces the Java app JH wrote # in 2008, but that is becoming more difficult to # run on platforms that have added security measures. # STEP 1: begin by sourcing the R function source("http://www.biostat.mcgill.ca/hanley/BridgeOfLife/BoLfunction.R") # STEP 2: decide which lifetable you wish to animate # options: # 1 Sweden 1751-1851 Females ['COHORT' lifetable (LT), born 1751 ] # 2 UK 1870-1880 Males ['CURRENT'/'PERIOD' LT, using death rates from 1870s] # 3 France 1895 Males ['CURRENT'/'PERIOD' LT, using death rates in 1895] # 4 France 1895 Males ['COHORT' LT, cohort born in 1895] # 5 France 1895 Females ['COHORT' LT, cohort born in 1895] # (the year 1895 was chosen to contrast CURRENT vs COHORT) # (those born that year were 19 when WW I began) # 6 Switzerland 1895 Males ['cohort' LT, cohort born in 1895] # 7 Switzerland 1895 Females ['cohort' LT, cohort born in 1895] # 8 Canada 2000-2003 ['current'/'period' LT, using death rates in 2000-2002] # STEP 3: After making the plot window as large as possible, call BoLfunction(option = 1, # or replace the 1 by another option 2-8 n.cohorts=1110, # change as desired DELAY=0.1) # change as desired # NOTES # When you call this function to animate the option, # You might want to experiment with the DELAY parameter # that indicates how many seconds delay between frames # On JH's MacBook Pro, 0.1 seconds works well, # On faster machines/slower machines, you might want to # change it to say 0.05/0.5 seconds # the FIRST TIME you try it, you might want to play # quite slowly (e.g. 5 seconds/frame) just to see HOW IT WORKS: # ie 10 have their 0-th birthday (are born) # the cohort immediately moves on 1 year, and each member either # survives the year (shown as a green dot) or dies during it. # The latter 'events' are shown in red. # every green dot counts as a full person year (PY) lived # every red dot counts as 1/2 a PY lived # The next cohort appears, etc... # the age-specific numbers of deaths during the year (the cycle) # are also shown in red underneath the first panel. # for the first 110 cycles, the app displays in green # in the second panel the number alive at each age # and in red in the third panel the number of deaths at each age # 110 years after the very first cohort was 'born' # (ie after the app reaches steady state) ... # the app displays in green in the second panel the AVERAGE # (over the cycles thus far) number alive at each age. # It is scaled up by 10, so it is out of 100 born. # it also displays in red in the third panel the AVERAGE # (over the cycles thus far) number who dies at each age. # It is also scaled up by 10, so it is out of 100 born. # It displays as red dots the rate of deaths per PY, # and as a red curve the logs of these age-specific death rates # (the log-linearity was first noticed by Gompertz and Edmonds). # The n.cohorts parameter indicates how many cohorts # (each of size 10) will make their appearance. # It also denotes the numbers of cycles # Think of a cohort as you and 9 birthmates born at the same # time, and the cohort behind you as another 10, etc... # (there isn't room to show your entire birtcohort at once)