Last active
August 7, 2020 06:28
-
-
Save catherio/8d95858c0f69023a9d5427fc5ef02671 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CAR (Case Ascertainment Ratio) hand-entered by CO from https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7239078/bin/NIHPP2020.04.29.20083485-supplement-1.pdf | |
# PTR (Positive Test Rate) hand-entered by CO from https://covidactnow.org/?s=830154 | |
CAR_and_PTR = { | |
'AK': [0.18, 0.032], | |
'AR': [0.13, 0.071], | |
'AZ': [0.09, 0.115], | |
'DE': [0.09, 0.179], | |
'HI': [0.13, 0.019], | |
'IA': [0.08, 0.129], | |
'KY': [0.06, 0.155], | |
'MD': [0.07, 0.231], | |
'ME': [0.2, 0.054], | |
'MI': [0.17, 0.239], | |
'MN': [0.19, 0.078], | |
'MT': [0.09, 0.033], | |
'ND': [0.23, 0.041], | |
'NH': [0.08, 0.117], | |
# 'NJ': [0.12, 0.40], # at least; omitting as this seems like a weird datapoint | |
'NM': [0.09, 0.058], | |
# 'NY': [0.19, 0.40], # at least; omitting as this seems like a weird datapoint | |
'OK': [0.11, 0.059], | |
'RI': [0.12, 0.156], | |
'SD': [0.04, 0.249], | |
'TN': [0.13, 0.071], | |
'TX': [0.06, 0.111], | |
'UT': [0.19, 0.061], | |
'VA': [0.11, 0.211], | |
'VT': [0.19, 0.048], | |
'WV': [0.11, 0.047], | |
'WY': [0.12, 0.029], | |
} | |
car = [CAR_and_PTR[k][0] for k in CAR_and_PTR.keys()] | |
ptr = [CAR_and_PTR[k][1] for k in CAR_and_PTR.keys()] | |
import numpy as np | |
[m, b] = np.polyfit(ptr, car, deg=1) | |
print(m, b) | |
# -0.3304898802394048 0.15667841037843105 | |
def trim(num): | |
return"{:.2f}".format(num) | |
print("Most optimistic:", trim(1/b)) | |
print("Least optimistic:", trim(1/(b+m*0.25))) | |
# Most optimistic: 6.38 | |
# Least optimistic: 13.50 | |
import matplotlib.pyplot as plt | |
plt.plot(ptr, car, 'o') | |
x=np.linspace(0, 0.25, num=50) | |
plt.plot(x, m*x+b) | |
plt.xlabel('PTR') | |
plt.ylabel('CAR') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment