Coder Social home page Coder Social logo

allcause's Introduction

All Cause Mortality Modeling

This repo contains all cause mortality data analysis for 2020 - 2022. The basic idea is that all cause mortality follows relatively predictable trends on a seasonal and yearly basis - excess deaths can be computed by subtracting the expected trend from actual deaths. This methodology is not impacted by reporting bias and can be used to evaluate the excess loss of life from 2020 - 2022. Expected trends were estimated using facebook-prophet.

For example, the chart below shows the expected deaths in blue and the actual deaths in red for this time frame:

alt text

Most of the data used comes from the National Bureau of Economic Research with 2022 estimates coming from the Centers for Disease Control. CDC data was used when NBER data was unavailable. For more information on this data transformation, see here.

Setup

Modeling was done in python 3.9.16. Virtual environments were managed with conda.

To get started, run

conda create allcause python=3.9.16 && conda activate allcause

To install requirements, run pip install -r requirements.txt

Data

Downloading 2022 Data

To download the CDC data for 2022, run the following source download_cdc.py. This should be fairly quick.

NBER Programatic Download

NBER data takes a while to download. To get everything, run

source get_data.sh

in the command line. If you don't need data from 1969, you can skip this step. Just expect long wait times in the app as you will be downloading data when you first run it.

Explanation

Most files can be download using the get_all_mortality_data in the allcause package. The only exception is for the year 1969. I hit some utf-8 encoding errors when calling pandas.read_csv on the link of the data but was able to circumvent them when I manually downloaded the data for this year.

Before running anything, you'll want to run the script download_1969.py. This will download the 1969 data, munge it, and delete the downloaded data. Or, you could do it manually. This is just more convenient. You will need to install Google Chrome to run this script.

If this is taking a long time, adjust the SECONDS_SLEEP parameter in download_1969.py - the program sleeps while the file downloads. I could probably do this with a promise, but I've got better things to do.

Running

To view excess death data, run streamlit run app.py in a terminal shell.

You should see something like this:

alt text alt text alt text

allcause's People

Contributors

jgwaugh avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.