<jupyter_start><jupyter_text>implied countsAdjust counts for time lags and unconfirmed cases.<jupyter_code>%load_ext autoreload
%autoreload 2
%autosave 0

import etl
from pandas import DataFrame

FIGSIZE = (9, 3)<jupyter_output>The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload<jupyter_text>realized countsLoad examples from [CoronaWatchNL] via <EMAIL>.[CoronaWatchNL]: https://github.com/J535D165/CoronaWatchNL<jupyter_code>real = etl.rivm().loc[:'2020-03-30']
real.plot(figsize=FIGSIZE, logy=True)
real[::5]<jupyter_output><empty_output><jupyter_text>implied exposuresAssumptions:- False-positive rate P(confirmed | not exposed) = 0.- Confirmation rate P(confirmed | exposed) = `cprob`.- Confirmations occur `ctime` days after exposure.**Caution:** If testing is common, then ignoring false positives leads to the [prosecutor's fallacy].[prosecutor's fallacy]: https://en.wikipedia.org/wiki/Prosecutor's_fallacy<jupyter_code>cprob = 0.01
ctime = 5

exposed = (
    real['confirmed'].rename('exposed')
    .div(cprob).shift(-ctime, freq=real.index.freq)
)
data = real.join(exposed, how='outer').diff()
axes = data.plot(figsize=FIGSIZE, grid=True, logy=True, title='new cases')<jupyter_output><empty_output><jupyter_text>implied fatality ratesAssumptions:- Unconfirmed cases are never fatal.- Deaths occur `dtime` days after exposure.**Caution:** P(deceased | exposed) may be much less than [case fatality rate].[case fatality rate]: https://en.wikipedia.org/wiki/Case_fatality_rate<jupyter_code>dtime = ctime + 7

confirmed = real['confirmed']
deceased = real['deceased']

cfr = deceased[-1] / confirmed.iat[-(1 + dtime - ctime)]
ifr = deceased[-1] / exposed.iat[-(1 + dtime)]
print(f"{cfr.round(3)} deaths per confirmed case")
print(f"{ifr.round(3)} deaths per implied exposure")

data = DataFrame(real['deceased'].rename('realized'))
data['expected'] = cfr * real['confirmed'].shift(dtime - ctime)
axes = data.diff().plot(figsize=FIGSIZE, title='new fatalities')<jupyter_output>0.181 deaths per confirmed case
0.004 deaths per implied exposure
{'fraction_non_alphanumeric': 0.14059500959692897, 'fraction_numerical': 0.01871401151631478, 'mean_word_length': 6.554347826086956, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '545082', 'license': 'Apache-2.0', 'n_tokens_mistral': 746, 'n_tokens_neox': 697, 'n_words': 164, 'path': 'books/implied.ipynb', 'repo_name': 'samkennerly/covid19', 'size': '2104'}