Visualizing Covid-19 trends

Many websites and news outlets provide coverage and analysis of Covid-19 trends. Graphs and maps are among the best way to convey them, but I can never find the combination of data most interesting to me. Google, for example, has great tools to show changes over time at the county, state, and national levels; but the comparison of regions against each other is limited and clunky. The Johns Hopkins Covid Dashboard meanwhile has heatmaps for easily seeing how regions compare against each other, but the data are only a single and recent snapshot. One of NPR’s most interesting graphs overlays the new cases in all 50 states, but does so with logistical scales that show daily new cases as a function of total cases rather than calendar date; and only one state may be compared against just New York at a time.

I set out to improve the situation for myself by rendering the raw CDC data, updated daily, with my own choice of axes and metrics. The publicly available result is an interactive combination of a line graph and heat map, both powered by amCharts, which mutually update each other’s state. The user may select which core data set to draw from, how to aggregate that data, and then either which date to focus on or which two states to compare. Most significantly, the line graph plots the median and the top- and bottom-five states — key percentiles — for a given data aggregation to show how outlier states change in both value and identity over time.

The default view shows the rolling 7-day average of new cases per 100,000 residents in each state. The top graph shows the daily top- and bottom-5 states as well as the median state sandwiched between them. The heat map below shows all states on a given day.

Continue reading “Visualizing Covid-19 trends”

busy final days for an often divided 2017-2018 Supreme Court

The last week of any Supreme Court term is usually pretty packed as the justices put the finishing touches on the last of their opinions. This last term’s final week was particularly rough. Several closely watched cases disappointed by avoiding broader issues on technical or procedural grounds, especially with regard to gerrymandering. Other cases made sweeping reversals whose effects might take time to see. Perhaps most controversially, the Court upheld Trump’s travel ban as a lawful exercise of executive power. And a lot of last-minute decisions were 5-4 splits right down the Court’s well-accepted ideological fissure.

Front row from left: Ginsburg, Kennedy, Roberts, Thomas, Breyer. Back row from left: Kagan, Alito, Sotomayor, Gorsuch.

Following are some highlights (mostly gleaned from Oyez’s lengthier summaries and supplemented in places by additional sources) from only the last ten calendar days of the Court’s term, organized by topic and presented in the form “case — vote (majority author) — holding” with details on facts and opinions.

Continue reading “busy final days for an often divided 2017-2018 Supreme Court”

official 2016 registration numbers corroborate Democratic disaffection

Trump’s upset victory over Clinton last year surprised just about everyone. Particularly since he lost the popular vote by nearly 3 million ballots, I wanted to see how that election compared to other recent ones to better understand how much of an outlier Trump’s victory was. To more fairly compare election results across their different electorates, I wanted to normalize the vote share won by each party, and I chose to do it by dividing votes cast into the number of registered voters for each state [1]. The Census Bureau aggregates that registration data for each federal election, but the result for a given election isn’t certified and published until well into the following year.

I experimented with several regression techniques on the historical registration figures to approximate the 2016 result and ultimately settled on a simple linear regression for the analysis. In May of this year, the Census Bureau released the official registration data and I’ve now been able to calculate the actual vote share. It appears that the regression approach was a relatively accurate predictor, which further corroborates my earlier claim that a widespread “enthusiasm gap” primarily hurt Democrats in 2016.

Continue reading “official 2016 registration numbers corroborate Democratic disaffection”

CenturyLink modem-less fiber connection

I was recently forced to switch from Comcast to CenturyLink following a move across town. The Comcast agent was no help in retaining me, and I actually got a call back from her manager inquiring at my low rating, but suffice to say Comcast couldn’t even confirm my new address. I won’t be missing that company.

CenturyLink on the other hand has been mostly snappy and surprisingly knowledgeable about their configuration. They had to drop a fiber line down from the utility pole and re-purposed the snipped cable line to get into the house (Comcast had no record of previous business at this address?), but then we were up and running with two proprietary devices of theirs: an Optical Network Terminator (ONT) and a ZyCell combination DSL modem and wireless router. I’d never seen anything like either, and it turns out you don’t need the modem/router if you have your own and are willing to play with some settings.

Optical Network Terminator left, ZyCell C1100z right.

Continue reading “CenturyLink modem-less fiber connection”

techniques for comparing relative election turnout

Earlier this month I published a deep dive into the evolution of presidential elections in the 21st elections. The primary motivation for that, aside from better understanding the shocking result of Trump’s victory over Clinton, was to analyze the widely made observation that Clinton won the popular vote by a particularly large number of votes. Around the time of that publication, updated vote tallies from a few large states (California, New York, and to a much smaller extent Pennsylvania) allowed for another shocking headline: Clinton won more votes than Obama did in 2012.

That headline (correct though it was by 90,000 votes, or 0.15% more than Obama’s 2012 haul) served to further distract from the thesis of my piece, which was that Clinton’s campaign resulted in a significant relative dip in Democratic turnout across virtually all states. But amid the drumbeat of considering absolute vote totals across elections, one criticism of my approach was to question the utility of performing a relative analysis at all. And if it was going to be made, why choose overall voter registration to  factor significantly into that analysis? This post more thoroughly considers the motivations for and alternatives to these choices to better explain why these methods probably best help us to measure differences between presidential elections.

Continue reading “techniques for comparing relative election turnout”

Clinton’s 2016 defeat explained: a statistical analysis of 21st century presidential elections

A popular indignant refrain among certain disaffected Democrats and progressives following the disastrous 2016 election is to point out that Clinton won the popular vote. It is true that at time of writing she leads Trump by more than 2.5 million votes nationally; and that’s nearly five times the margin that Gore had over Bush in 2000, the last time the popular and electoral votes disagreed. How then could Clinton have lost the Electoral College so roundly unless it were a truly undemocratic or even sinister distortion of the popular will?

Though there certainly are valid criticisms of the Electoral College which one could use to argue against its continued existence, it turns out that the raw number of the national vote in 2016, while stunning, isn’t one of them. The furore over the disconnect in 2016 made me wonder about a far more useful measure of election turnout: vote share among registered voters, especially as compared with previous elections [1]. A rigorous statistical analysis of the available data suggest that the collapse of the Democratic coalition is alone to blame for its electoral defeat in 2016.

In this image, green means good for Democrats and orange means bad. Who do you suppose won this election?

Continue reading “Clinton’s 2016 defeat explained: a statistical analysis of 21st century presidential elections”

image rotation through metadata

I’ve got a fancy camera that writes what’s called EXIF (EXchangeable Image Format) metadata into the image about, among many other things, the proper orientation of the image. That’s pretty nice since it means that all the images have the same dimensions (width by height) when written to disk, but unless your rendering software respects the metadata and spins the pixels accordingly when writing them out to a monitor, looking at your images can leave you with a real crick in your neck. Jump to the bottom of this post for solution code, but read on for entertainment.

Continue reading “image rotation through metadata”

hello again world

Assuming you already have MySQL installed, adding a marginal wordpress site isn’t hard so much as it isn’t easy. This site is somewhat helpful.

Step I: plop down the wordpress bits wherever you want, and set up wp-config.php with the essential details of DB_USER and DB_PASSWORD. Thank goodness it’s php, so keeping those values in plaintext is completely safe. The super key detail is the DB_NAME of the new database which will be exclusively used for your new site. Of course make sure that you can load up index.php from those wordpress bits through some kind of webserver config.

Step 2: actually create that DB_NAME database in MySQL Workbench. I kinda thought wordpress would just make the db if it wasn’t there, but it actually throws an error. You need to make the db, but you don’t have to specify any details about it except its name (which should be the same as DB_NAME) and its charset encoding (probably a good idea to set this to the DB_CHARSET in yr wp-config.php, but obviously this is undocumented since MySQL has like eleventeenhundred utf-8 settings; I went with the default-iest of those and it seemed to be fine).

Step three: navigate to yoursite.domain/yourblog/wp-admin/install.php. This will prompt you for a username and password. This seems really unsecure until you consider that it tests your local db for a well-configured schema (given its version?) and only does anything if it hasn’t already been set up. So don’t do Step 2 and then not do Step three for hours or days because then some hacker might set up a blog on yoursite.domain and pretend to be you. Anyhow the rest is simple clicking and then your wordpress site will be generally accessible for reads but password protected for edits.

Step IV: rant insufferably.