26 August 2024

A simple fair method to ration medical resources between facilities

Based on Raffensperger, John F., Marygail K. Brauner, and R. J. Briggs, Planning Hospital Needs for Ventilators and Respiratory Therapistsin the COVID-19 Crisis. Santa Monica, CA: RAND Corporation, 2020.

In this post, I explain how to implement our method using a spreadsheet.

Medical administrators face the problem of allocating resources such as ventilators among different facilities when demands vary extremely. Administrators may be able to forecast average demands at each facility by day or week, but must still manage the variability of demand over minutes and hours. Different average demands among smaller and larger facilities complicates the allocations further. Queuing processes are non-linear, so proportional allocation methods (such as allocating based on average ventilators per patient) can result in inefficient and unfair outcomes.

To efficiently and fairly ration resources between facilities, we propose application of a classical queuing model, enabling administrators to define fairness as equal waiting times across facilities. Administrators can easily run the model in a spreadsheet or other computer system. Using the queuing model, the administrator allocates resources to equalize the wait time among facilities. Due to the non-linearity of waiting time as a function of the number of resources, equalizing wait times across facilities also minimizes total waiting time.

This method of equalizing wait times across facilities is not meant for use in prioritizing patients within a facility, nor for rationing resources between patient types, e.g., by age or socio-economic status. Our method assumes that the population of patients at one facility are clinically similar to the population of patients at other facilities.

With clinically similar patient groups, we can use a classical queuing model to allocate resources. The Erlang C formula was developed by Agner Krarup Erlang in the early 1920s to determine the number of telephone circuits required in a telephone exchange. The formula is appropriate for multi-server queues (where servers are the resources such as ventilators within a hospital), and where arrivals and service times follow Poisson distributions.

λ is the arrival rate of patients, e.g., arriving patients per hour at a hospital.

μ is the treatment time (length of stay) on a single server, e.g., average hours that a patient is on a ventilator.

N is the number of servers, e.g., ventilators at a hospital.

Poisson(N, ρ) is the probability of exactly N events occurring in a fixed interval of time when the average occurrence rate is ρ, such as λ*μ in this case.

The probability of wait is as follows:

Prob(wait > 0) = Poisson(N, λ*μ)/[Poisson(N, λ*μ) + (1λ*μ/N))∑k=0N–1 Poisson(k, λ*μ)]

As the probability of wait approaches 100%, the average queue gets longer. If the probability of wait reaches 100% or greater, patient load exceeds hospital capacity, and the queue length will explode. When the formula exceeds 100%, the reader may not find the value to have intuitive meaning, so we can restrict the calculation to a maximum of 100%:

Prob(wait > 0) = MIN(1, POISSON.DIST (N, λ*μ, FALSE) /

(POISSON.DIST (N, λ*μ, FALSE) + (1 – λ*μ/N))*POISSON.DIST (N – 1, λ*μ,TRUE)))

To build the full spreadsheet, proceed as follows:

1. Write a spreadsheet row for each facility. Each row has the facility’s current number of resources (e.g., ventilators), the average arrival rate of patients per day, and the average service time per patient (e.g., days on ventilator).

2. In each row, add a cell with the expected waiting time for each patient, using the Erlang C formula we give below.

3. Given the number of new resources to allocate across facilities, give the next available resource to the facility with the longest patient waiting time. Of course, with a new resource such as a ventilator, the facility may also need more resources of other types, e.g., respiratory therapists. The spreadsheet can calculate these other resources as well, if appropriate data (e.g., ventilators per therapist) is available.

Here is an example in Google Sheets.

28 June 2023

How to Set A Deadline On Global Warming

Friends, colleagues, I have just published GEO-X: How 10 Big Firms Can Lead Us to End Global Warming. You can get it free through July 2023 on Apple Books, https://books.apple.com/book/id6450712229.

I ask for your help in distributing it to business executives, especially to executives of environmental sustainability.

“GEO-X” examines the political obstacles to ending global warming and concludes that governments will probably never overcome them. The book describes the weaknesses of existing regulatory systems, how they slow emissions but fail to incentivize true net zero operations, much less the enormous carbon removal required to reverse global warming. The book explains the failures of the carbon removal markets, especially the moral hazard so often resulting in fraud.

To solve all of these problems simultaneously, “GEO-X” proposes a bold three-part solution.

First, a coalition of willing firms could start a Global Emissions and Offset Exchange (GEO-X) to trade emissions permits and carbon removal contracts. Participating firms would end business with non-participating firms. The result would likely be a rush to join through the global supply chain.

Second, GEO-X would strengthen the carbon removal market with contracts backed up by modern data and biological simulation. GEO-X would not pay for reducing emissions, but only for removing carbon from the air.

Third, GEO-X would clear the carbon market with a state-of-art auction mechanism which prices a hard deadline on global warming. This auction mechanism appears to be the most efficient emissions trading system ever designed.

GEO-X would not need government to start, but would benefit from government cooperation. Governments could require businesses within their jurisdiction to participate in GEO-X, accelerating global participation.

“GEO-X” calls senior business executives to tackle global warming head-on.

Get it now and send it to your boss! And please re-post to your own networks.

#climateaction #climatechange #ClimateLeadership #ClimateSolutions #ClimatePolicy #corporatesustainability #environmental #globalwarming #markets #supplychain #sustainability

23 May 2023

The Art of the Spreadsheet is now published

My new book The Art of the Spreadsheet is now available on Amazon. This high-quality full-size color paperback that will help you make much better spreadsheets. It's got some surprises in it that seem to go against the common wisdom. It also has powerful Visual Basic macros to help you audit your spreadsheets.

Look for the chapter about the Nobel Prize winner's spreadsheet!

08 May 2021

Calculator for COVID-19 population immunity, likely optimistic

I wrote a simple spreadsheet to estimate the approximate level of immunity for a given area. The inputs are the 

  • population,
  • number vaccinated,
  • number of COVID-19 cases.
The key output is the fraction of the population 18-years-and-older with some level of immunity, either from having been sick or from having at least one vaccination. 

Here's the spreadsheet:  US percent immunity.

Looks like very good news to me! The U.S. as a whole appears to be at about 80% as of this writing.

21 April 2021

A Faster Path to Ending Global Warming - and I mean Ending It

National and international negotiations to address climate change are hard. So hard, in fact, that the progress we've made in over a half-century of knowing about climate change is slight.

I've got a new publication which explains how to solve this problem: "A price on warming with a supply chain directed market," in Springer's new journal Discover Sustainability vol, 2, no. 2, Feb 2021.

I've also produced a YouTube video about this work: "A Faster Path to End Global Warming: A Price on Warming with a Supply Chain Directed Market."

Much more to come!

 

12 April 2019

Quit Fox News

If you love your family, if you love God, if you love your country, repent of watching Fox News. Now.

05 July 2018

Corporations shouldn’t have “free speech” for this one weird reason

They can’t go to jail. The government can fine them, but the government cannot take away their physical liberty.

Nor do corporations vote; a corporation is not and cannot be a citizen.

A for-profit corporation is a tool of commerce, like a butcher’s scale, a credit card, an accounts book, and an advertisement. That a corporation is more than an commercial device is a lie, a lie born out of deceit.

Because the corporation is inherently a tool of commerce, corporations should be regulated like any other commercial device. Government reasonably demands that butcher’s scales show true weight, that credit cards are charged fairly, that accounts are accurate, the banks faithfully hold their customers’ deposits and report those deposits accurately. When a business cheats with these ordinary tools of commerce, consumers rightfully expect government to prosecute the people running that business. Corporations are creatures of the market place, not of politics, and the market place must be well-regulated.

Now, companies already freely say bald-faced lies: cigarettes are good for you, coal is clean, global warming is a scam, that pollution isn’t from our plant, that pollution won’t hurt you, and the doozy “Corporations are people, too, my friend.”

If government allows corporations “free speech” on the basis of the First Amendment, then what is to stop corporations from claiming the right to say anything at the butcher scale with how much meat you are buying, with the credit card in how much you owe, and the accounts book in how much money you have on deposit? If a bank has the right to free speech to tell you whatever they want to say, then they can tell you that your bank balance is whatever they want to tell you it is. We should be surprised and offended if the butcher’s scale showed a different weight depending on the customer’s politics, or sexuality, or religion. These examples are (hopefully) obviously absurd.

Government should treat corporate lies in exactly the same way as it does a dishonest butcher’s scale. Government must require corporations to speak the truth, and to stay out of politics, for the same reason that a butcher’s scale should tell the truth and should stay out of politics. If you go into business, then you should treat everyone equally, and honestly, even if you dislike their politics, sexuality, or religion. And if you, in the course of your business, do not treat everyone equally and honestly, you should be prosecuted.

28 April 2018

I'm quitting Facebook

Friends, family, I have decided to quit Facebook. I have thinking of doing so for some time.
I'm quitting Facebook because I think its small benefits are swamped by its terrible costs. The benefits include a convenient way to interact with friends and family, a software interface that encourages sharing of thoughts and personal experience, opinion, links to other people's opinions, links to other news articles, sharing of photos. The interface is intentionally addictive. It is fun. It is nice to see what other people are thinking about. I feel like I connect with others when I use it.
The downsides of using Facebook are hidden. Here are some I have found.
And if you believe you are immune, you are deluding yourself! We soak up other people's emotions through Facebook,
http://www.pnas.org/content/111/24/8788
Now then, I ask that you to consider quitting Facebook as well. We need to stop being suckers, we need to prevent the horrible influence on our elections to the extent we can, and we need to send a signal to the technologists that they have to stop taking advantage of us. We need to take down this platform.
I do not make this decision lightly. I enjoy Facebook. I like seeing what family and friends are doing. It is fun. Nevertheless, their business model is surveillance and hyper-targeted advertising; they make money on extremism and ripoffs. I can't be part of this, and I wish you were protected from it as well.
Please have a think about it, read some articles about it, think about the effect of its downsides on society, and compare your own fun with it to these drastic downsides. Further, with some irony, I invite you to share this post with everyone you know, forward it to your friends and colleagues, send it in emails to your family. We need to take this on together.
Even though I am quitting Facebook, I very much wish to maintain contact with you. Please feel free to write me at my personal email address.

10 December 2017

The Correct Price of Bitcoin

I noticed the crazy Bitcoin bubble, and tried to think about what its price should be. I think I've come up with a model for it, based on the optimal inventory of Bitcoin for a Bitcoin user. This idea follows from the optimal inventory of cash.

The basis for this model is the idea is that we need a supply of cash for purchases over the year, perhaps our demand is d = $500/year. To take cash out of the bank, we lose the interest i, perhaps 1%,  on that money. So we are incentivized to take out only small amounts. But taking cash out of the bank has a fixed cost f, including any withdrawal fee (as from a banking machine) and the hassle of getting to the bank, perhaps $2/transaction. The fixed cost of withdrawal incentivizes us to take out large amounts.

So the two competing costs have an optimum, which we can calculate using the classic Wilson economic order quantity formula. For more background on the optimal inventory of cash, see this, which references Baumol. The economic order quantity formula is Q = (2fd/i)^0.5, where Q is the optimal withdrawal amount.  Assuming we use the cash evenly over time, we will have on average $Q/2 dollars in our pocket.

We can apply this model to Bitcoin to estimate its correct price. Assume:

  • a 3% interest rate, and 
  • a $2/transaction withdrawal fee to get Bitcoin (e.g., to convert it from $US),
  • users want to spend about $500 worth of Bitcoin per year.
Using the formula above, we find that each user would hold on average about $129 worth of Bitcoin.

Assume 20,000,000 Bitcoin users. Together, they need $129*20,000,000 = $2.59 billion Bitcoin.

With 21,000,000 Bitcoin in existence, the Bitcoin should cost $2.59 billion/21,000,000 = $123/Bitcoin.

I tried this on the amount of U.S. currency, and was off by a factor of approximately 2, which could be due to people hoarding cash. So let's multiply by 2 for hoarding. We get a price of Bitcoin of only $246.

Below is some sensitivity analysis. I think $15,000 is really high!

Low Geometric mean High
Max number bitcoin 21,000,000 15,874,508 12,000,000
Number of users 20,000,000 44,721,360 100,000,000
Interest rate/year 3% 1.7% 1%
Transaction cost $2 $2.83 $4
Demand/year/user $500 $1,414 $4,000
Optimal holding/user $129 $340 $894
Total cash needed $2,581,988,897 $15,196,713,713 $89,442,719,100
$/bitcoin $123 $957 $7,454
With hoarding, x2 $246 $1,915 $14,907

I put the calculated fields in bold.

The world has few substitutes for US dollars, because many things can be purchased only in US dollars. The world has a lot of substitutes for Bitcoin - the only people who accept only Bitcoin are thieves. And Ethereum looks like a much better cryptocurrency, with its smart contracts and higher trading rate.

And what do you get when you buy Bitcoin? You get a secret number. That's pretty much it.

This Bitcoin bubble is a zero-sum game. When you take money home, someone else is likely to lose it. A true pyramid scheme, with the Winkelvoss twins at the top. My advice? Get out while you can.

10 May 2017

New book: Smart Markets for Water Resources, by Raffensperger & Milke

Friends and colleagues, I am pleased to announce the publication of Smart Markets for Water Resources - A Manual for Implementation, which I co-authored with Mark Milke.

We worked so hard on this book! I hope that it starts a revolution in water allocation.

16 October 2016

Truth, Justice and the American Way

Google News has a new fact-check feature. Wonderful!  Technically-oriented folk might enjoy a look at the schema that someone has proposed for it.

The world so desperately needs this. This could help change the world.  Now, we just need to get the news and pseudo-news services to have scrolling fact checks at the bottom of the screen.

Here are some other comments on it from the CS Monitor, and a disturbing commentary on fact-checking from the Washington Post.

14 December 2015

Are lies justified?

NT Times has a sad article about lying, The author, a professor of philosophy, poses 10 cases in which he believes that lying is justified.

I am inclined to agree with a few of them. For rexample, #6 is, "In November of 1962, during the Cuban Missile crisis, President Kennedy gave a conference. When asked whether he had discussed any matters other than Cuban missiles with the Soviets he absolutely denied it. In fact, he had promised that the United States would remove missiles from Turkey." I don't know what else was going on, so I am inclined to let him off the hook. Still, I think that the President could have said, "I won't discuss matters of national security."

For most of the list of 10 dilemmas in the article, a little thought provides a truthful alternative. For example, "9. I am negotiating for a car with a salesperson. He asks me what the maximum I am prepared to pay is. I say $15,000. It is actually $20,000." Why not just say, "I would like to pay around $15,000"?

But the article is sad for what it implies about lying, that lying is now part of our culture, that lying is acceptable. I so wish this to be false!  I don't want to live in a nation of liars. What about the tobacco companies lying about the dangers of smoking, or the oil producers' elaborate misinformation about climate change, or Volkswagen's deception about their cars' pollution? What of those Nigerian phishing emails we get, promising us 50% of $1.2 billion? The ads that tempt our vanity, "try this one weird old trick to lose 30 pounds in a week"?  Donald Trump's statements about immigrant rapists and a fantasy two-thousand-mile-long wall to keep them out? Or shall we become a society of lies like Russia?

Prof. Dworkin! How about an article that helps people finesse their ways through complex situations with integrity?  How about a set of brain teasers, "Here are some ethical dilemmas, now find the honest way through them"?  Can you give us reasons to speak the truth, not reasons to lie?

Think about what you want from your grocer, from your employer, from your family, from your friends. You want them to be straight with you, to be honest with you, to deal with you in genuine fairness. The only way we as a society can have this is if we all choose to be honest ourselves.

07 October 2015

The Death of Fox News

Hyperbole? I hope not. We have to figure out how to prevent people from making money through lies.  The good news is that fact checking is getting widespread on the Internet. Helpers like Politifact have been around awhile (though they themselves subject to accusations of bias by openly partisan conservatives).  But some cool new tools are on the horizon.

First, Facebook is adding tools to let users flag lies. I'm often tempted to click on "Heidi Klum" (no link provided here, LOL), but I can't bring myself to click on "Santa Claus proved to be real!"  But some of us are tempted by headlines like that.  'Cause we're all different amounts gullible.

Second, and probably more usefully, Google is working on an automatic fact checker, as the Washington Post reports.  Here's Google's paper on it. Years ago, I had a similar idea, and I'm very glad to see Google making progress on it. (Google is also working on making high-quality health information available.)

Now imagine that you can download a widget that scans your (Fox) webpage or video, and checks the statements in real time. And imagine that the widget reports to you in real time which statements are false, and the running fraction of obviously false statements. If you're like me, you would lose confidence in that website or video, and tend to avoid it in the future.

I think that would be a better world.

13 June 2015

Cornell Food & Brand Lab, saving money, and open source academic journals

TreeHugger has an article about food waste. The article describes a recent academic paper done by Porpino, Parente & Wansink, "Food waste paradox: antecedents of food disposal in  low income households," Intern'l J. of Consumer Studies, 2015. Unfortunately, the journal article is behind the Wiley pay-wall. The first two authors are at the Getulio Vargas Foundation, Brazil, and the third author is at Cornell.

The TreeHugger article gets the summary right. Here's the Cornell summary. Have a look at them. But here's my take on it.

You can save money by doing bulk purchases only if you are sure you will use it all. You can save money by preparing smaller quantities, to ensure you can eat it all. You will save a lot of money by getting rid of your dogs and cats (okay, this is incendiary, hold your flames on this until I can write a fuller post, I'm just reporting my interpretation of the journal paper). You can save money if you conserve food more carefully - like closing that bread bag all the way, so it doesn't dry out.

My suggestion: drive down your food inventory to near zero occasionally, say, at least every 6 months. Eat what you have on hand. Empty out the fridge, empty out the cabinets and the pantry. Force yourself to eat up the weird stuff, the dried beans, the ancient packages of foreign noodles, that you've been ignoring. Imagine not needing to go to the grocery store for two weeks!  You'll save a ton of money, clean out the cupboards, and learn more about which foods you're actually going to use.

The TreeHugger article pointed me to the Cornell Food and Brand Lab site. Lots of great material there. In their short video, Porpino has sad eyes, as if he is unhappy about the food waste. I liked the video, and the cart-to-trash action makes the point well. Here's another interesting article by the Cornell Lab folk: whether you lose or gain weight depends on weekdays, not weekends.  Great stuff, great work. Whoa, Wansink has the same baggy eyes as Porpino!  They are obviously working overtime to bring us all this great research. Kudos, guys, keep it up.  But consider PLoS One for your next article - your lower-income Brazilian study subjects could then read it. In any case, I'll be coming back to your Lab website.

04 May 2015

On failure in diets

The Washington Post has an interesting interview with Prof. Traci Mann. In the article (and a related book, which I have not read), she describes her research about dieting.  As I understand it, she thinks that dieting will almost always end in failure.

Based on my own experience with Wagmu, I have felt for some time that dieting is fraught with problems. The interview described physical changes that I have felt myself during dieting - more attention to food, finding greater pleasure in food, lowered metabolism, difficulty in maintaining willpower. I find much to agree with.

I disagree, mildly, when I consider the use of tools for dieting.  In particular, logging one's diet has been shown to improve the efficacy of dieting.  See for example this report. I have found that when I am logging food in Wagmu, I am succeeding, and when I don't log food in Wagmu, I am failing.

Something about the process of making a plan - "this is what I'm going to eat" - seems to ease my ability in sticking to the plan. My guess is that it's (1) the a priori commitment, combined with (2) a concrete plan, and (3) knowledge that I have a nutritious diet due to Wagmu's powerful Suggest feature.  So I've made a plan, and I know exactly what to do, and I know that if I don't follow it, then it won't be as nutritious.

So I'm hoping Prof. Mann tries out Wagmu!

02 May 2015

Drag your GraphViz nodes with Inkscape!

GraphViz is a great graph layout engine, and GraphViz outputs to SVG. This allows us to edit GraphViz output in Inkscape.

Unfortunately, this editing is limited. The arcs are not "connectors" in the graphic-editing sense, so we cannot drag a node while maintaining arc connectivity.

But Inkscape does have draggable connectors. Solution: I wrote this Python script to convert GraphViz SVG output to have Inkscape-draggable connectors. Seems to work. In Inkscape, click the node to drag, not the arc. Your mileage may vary.  Open source code here.

# 2 May 2015, John F. Raffensperger.

from xml.dom import minidom

# 1. Read Graphviz.svg. This is output from Graphviz.
graphvizSVGFile= minidom.parse("graphviz_output.svg")

# 2. For each node, get id and title.
nodeTitles = {}
for s in graphvizSVGFile.getElementsByTagName('g'):
    if s.attributes['id'].value[:4] == "node":
        nodeTitles[s.getElementsByTagName('title')[0].firstChild.data] = s.attributes['id'].nodeValue

# 3. For each arc, parse the title, and match the corresponding ids of the nodes, add the ids to the arc,
edgeTitles = {}
for s in graphvizSVGFile.getElementsByTagName('g'):
    if s.attributes['id'].value[:4] == "edge":
        edgeTitle = s.getElementsByTagName('title')[0].firstChild.data
        edgeTitles [s.attributes['id'].nodeValue] = edgeTitle.split("->")
        
# 4. Add connector elements to Graphviz.svg.
# For each arc, delete the GraphViz arrow marker,
for s in graphvizSVGFile.getElementsByTagName('g'):
    if s.attributes['id'].value[:4] == "edge":
        # Remove child "polygon", which is the GraphViz arrow marker.
        for thing in s.childNodes: 
            if thing.nodeType == s.ELEMENT_NODE and thing.tagName == "polygon": 
                s.removeChild(thing) 
                break

# 5. To each edge path, add an Inkscape arrow marker in the attributes.
for s in graphvizSVGFile.getElementsByTagName('g'):
    if s.attributes['id'].value[:4] == "edge":
        for thing in s.childNodes: 
            if thing.nodeType == s.ELEMENT_NODE and thing.tagName == "path": 
                thing.setAttribute("inkscape:connector-type", "polyline")
                thing.setAttribute("inkscape:connector-curvature", "3")
                nodeID = nodeTitles[edgeTitles[s.attributes['id'].value][0]]
                thing.setAttribute("inkscape:connection-start", "#" + nodeID)
                nodeID = nodeTitles[edgeTitles[s.attributes['id'].value][1]]
                thing.setAttribute("inkscape:connection-end", "#" + nodeID)

# 6. Output should have draggable nodes in Inkscape, after ungrouping as needed.
SVGtextFile = open("inkscape_input.svg", "wb")
graphvizSVGFile.writexml(SVGtextFile)
SVGtextFile.close()
print "done"

28 December 2014

Thieves, vandals, and "The Interview"

Our house got robbed last weekend. The thieves took generic electronics - computer monitors, TV, an old laptop computer - but also the bone necklace that I made for my wife years ago. We made simple mistakes in our security arrangements, mistakes that are easily and cheaply fixed.

But I think of the poor chump who got at most a couple hundred dollars from messing up my house, who put themselves and their family's welfare at such risk for such a little bit, how pitiful he or she must be.

I had a similar reaction to the Sony hacking. The fools running North Korea are in a desperate situation of their own making, without a clue as to what to do beyond vandalizing a movie company's computers in the lamest attempt at protecting their honor.

The feeling was accentuated further when we rented "The Interview" on Youtube (I was getting stir-crazy).  It's a stupid film.  A government actually got upset about this? And bothered to react?  It makes the film into a tragedy, and not only for all the people that were injured by the vandals, but for the vandal.

Then I read that people have been viewing pirated versions of the movie. People who watch pirated movies are stealing, but in this case, they're also siding with the antagonist of the film.

10 July 2014

Comments on David Brat?

The New York Times has an interesting article on David Brat and his belief that Protestantism is good for the economy. The article give modest background on Brat and his theories, but the fascinating bits are in the readers' comments. Check it out.