Sunday, May 17, 2020

Excess Mortality

When I first read about some of the challenges determining whether a death was due to covid-19, I wondered if it would be better to simply look at total deaths on a particular day this year vs. prior years.  It turns out there are a number of people and organizations interested in in excess mortality:

  • In Europe, EuroMOMO has charts and maps 
  • In the US, the CDC has a chart of weekly excess deaths
However, it's challenging to find data you can use to do your own analysis.  The CDC has publicly available mortality data, but this only records the month, not the day of death. 

Our World in Data has a nice article explaining the importance of excess mortality, the challenges of acquiring data to examine it, and publications that are tracking it.

Sunday, March 29, 2020

Flu deaths vs covid deaths

I feel like the fact that 10-20,000 people in the U.S. die every year from the flu isn't evidence that we should treat covid-19 less seriously, but that we should treat the regular flu more seriously.  

We can say "get vaccinated and if you do get sick with the flu, stay home."  Yet, the ability to take sick days is a privilege that not everyone has in the U.S. because our culture already prizes the stock market over human lives.

note: posted here on 3/29/2026 and backdated to when it was originally shared with friends on FB.  this is still a problem in the US

Sunday, February 9, 2020

Idle thoughts on term limits, Vermont political constipation edition

Vermont sends 3 elected officials to U.S. Congress: 1 Representative, and 2 Senators.  Over the last 45 years, a total of 6 men have held these positions.

The Representatives:


The Senators:


By years in office during the last 45:

  • Leahy: 45
  • Jeffords: 32
  • Sanders: 29
  • Stafford: 14
  • Welch: 13
  • Plympton-Smith: 2
... so 3 men have provided the vast majority of the representation for the entire state of Vermont at the national level since 1975.  

Because it's nearly impossible to unseat an incumbent**, these are essentially lifetime appointments, and over the decades many potential candidates for these positions are left waiting for "their turn".  Welch, the current Rep, waited 18 years between runs for the U.S. House after losing in the 1988 primary to Poirier, and generations of potential U.S. congresspeople from VT are getting old and grey waiting for Leahy, Sanders, and Welch to retire.  

Term limits might be the laxative we need.

** the only time it's happened in the last 45 years was in the 1990 U.S. House election when Bernie ousted Plympton-Smith, after coming a close 2nd when he and Paul Poirier split the Dem/Independent vote in the 1988 election.

Sunday, January 26, 2020

Gabriela Montero


We were fortunate to see Gabriela Montero in concert Thursday evening at the Flynn.  This was her first time in Burlington, which she kindly described as "pretty nice" despite the freezing temperatures outside and the undersized audience inside.  

The program "Westwards" featured two pieces by Prokofiev, a Rachmaninov, a Stravinsky, and a screening of Charlie Chaplin's silent film The Immigrant with Montero providing an improvised piano score.

The only Prokofiev I'm familiar with is "Peter and the Wolf", so needless to say I was surprised by the modern sound of his music, and I don't have sufficient musical theory/training to enjoy it.  

Rachmaninov is a different story, and his music is more welcoming and invites you in.  I enjoyed this section and the Stravinsky very much.

After the Stravinsky, Montero took a few minutes to talk about "Westwards" and the thematic and personal connections between these composers and Chaplin.    It was fun to see a silent film with piano accompaniment at the Flynn, though the Flynn opened at the beginning of the talkie era.

After the screening of The Immigrant, Montero once again took to the microphone to ask for a tune or theme from the audience, which she would then improvise upon.  She did this twice, and it was awe-inspiring to hear, and perfect for live performance.  I would have been delighted for the entire evening to have been her improvised compositions. 

Saturday, December 21, 2019

Netflix DVD rental history

We joined Netflix in late November, 2004, with the 3 DVDs out at a time plan. Nadal had yet to play at the French Open; Federer won his second Wimbledon and the U.S. Open; Phelps won 6 gold medals at the Olympics; the Boston Red Sox had won their first World Series in 86 years. And we had a 6-month-old. So we were trendsetters and cut the cable.
Fifteen years later, we're dinosaurs holding on to an old service. Yes, we have Netflix streaming, but had been holding on to 1 DVD out at a time for the past five years in order to see new releases a little sooner. However, we knew we would want Disney+, and the local library tends to carry new DVD releases, so it was an easy switch this fall.
Now, of course, I wanted my Netflix DVD rental history, but Netflix doesn't provide a download, so I had to select, copy, and paste from a webpage.

The resulting file was not a nicely formatted CSV. This provided a nice opportunity to practice some general file processing.
Examining the structure of the file, each rental takes up several rows; each row in order contains:
  1. A number indicating the order of the rental, from the most recent rental to the oldest (exactly 1500 rentals!)
  2. The title of the rental
  3. A blank line
  4. The release date, rating, and runtime; concatenated into a single string
  5. A blank line
  6. The ship date from Netflix's processing facility and the return date
Some rentals have an additional three lines, indicating:
  1. Whether the original shipment was damaged
  2. A blank line
  3. The ship date from Netflix's processing facility and the return date for the replacement disc


From this file format, I wanted to create an initial output table where each row was a separate rental, and each column was a line from the file (I would further process the output table later). My initial parsing script needed to identify a new rental based upon whether the value of the line was an integer, read intervening lines as elements of a list, and so the rental history was a list of lists to be transformed into an output table.
The core of this parsing code is as follows:
with open(filepath) as fp:
    line = fp.readline()
    record = []
    viewingHistory = []
    while line:
        try:
            int(line)
            # print(record)
            viewingHistory.append(record)
            record = []
        except:
            record.append(line)
        line = fp.readline()
    # This final append is necessary in order to get the final record in
    viewingHistory.append(record)
With the output table, I could use some of the visual tools in Dataiku to further prepare the data. Specifically, I:
  1. Removed the empty "junk" columns
  2. Remove the initial empty row created by my parsing script; I didn't bother to think of a clever way to not produce it
  3. Parsed out the ship date and return date from the column containing that information
  4. Computed the difference between the ship and return date to give how long we had the disk out in days
  5. Parsed out the release date, rating, and run time from the column containing that information. This required using a Python code step, and manually checking the various MPAA ratings in an order that would produce the desired results.
def process(row):
    # In 'row' mode, the process function 
    # must return the full row.
    # The 'row' argument is a dictionary of columns of the row
    # You may modify the 'row' in place to
    # keep the previous values of the row.
    # Here, we simply add two new columns.
    ratings = ["PG-13","NC-17","TV-PG","TV-14","TV-MA","TV-Y7","PG","NR","G","R"]
    for rating in ratings:
        split = row["infoblob"].split(rating)
        if (split[0] != row["infoblob"]):
            row["releaseDate"] = split[0]
            row["rating"] = rating
            row["length"] = split[1]
            break
    return row
With the prepared dataset, we can do some visualizations. An obvious start is the number of rentals per year. As a coworker noted, 2010 was an exciting year...

We can also look at the number of rentals by release date. As expected, most are recent years, but we clearly had a backlog of old movies we were working through, too.
Note that this only has 958 records, instead of 1500, because television shows did not have release dates. Further work on the project might be to capture that information, especially since it's a third of the rentals.

This is a visualization of how we worked through the backlog of old movies. The Y-axis is the age of the rental movie in years, so it's not just the release date of the movie that matters, but the release date relative to the year in which we're watching it. For the first several years, there's quite a lot of scatter in the age of the movies, but this peters out as we work through the backlog, and by mid-2014, we're renting only the occasional "old movie" and are focused primarily on new releases. This is also when we decided to go to 1 DVD out at a time.

I'm not sure there's anything to build a model on. That may come later.