{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Code for BHM (2020) and user interface" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1. What does this code do?\n", "\n", "This code replicates Figure 6 in Berger, Herkenhoff, Mongey (2020) - *An SEIR Infectious Disease Model with Testing and Conditional Quarantine\".\n", "\n", "To replicate this figure for a number of different rates of testing $\\left(\\tau\\right)$ follow these instructions:\n", "1. Scroll down to the first 'cell' below, place cursor inside the cell, then press Ctrl+Enter.\n", " - This will compile some code and present the baseline calibration of the model\n", " - Ignore these if you wish to replicate Figure 6\n", "1. Click the button marked **[Run model]**\n", " - The code will take ~45-90s to run the model, and then display **\"Done solving model\"**\n", "1. Click the button marked **[Show panel chart]** to display the figure\n", " - Accompanying the figure will be a slider for $\\tau \\in [0,0.05]$ (from zero to 10 times the value used in the paper), that can be moved to change the plot\n", "\n", "Below we describe other parameters. To change other parameters refresh this page in your browser. Repeat the above and then before pressing **[Run model]**, choose alternative values for model parameters.\n", "\n", "**To download the underlying code, please follow the link to 'Download underlying model files' at http://www.simonmongey.com, or alternatively access the files at http://www.github.com/simonmongey/covidtesting. This code can be ran, more quickly and offline using Jupyter Notebook**\n", "\n", "### 2. What can I change?\n", "\n", "- There are two sets of parameters that the user can change\n", "\n", "#### 2.1 Preset parameters\n", "\n", "The first set appear in Table 4 of the paper, and below are divided into three blocks\n", "1. **Quarantine parameters**\n", " - $\\xi^u\\geq 0$ \n", " - Baseline rate of quarantine that is used in the *Common quarantine* case\n", " - $\\lambda^Q/\\lambda\\in[0,1]$ \n", " - Effectiveness of quarantine. If equal to 1, then quarantine has no effect. We suggest in the paper that for Wuhan this is around 0.10, and use 0.50 as our baseline for counterfacutals\n", " - $A_{rel}\\in[0,1]$ \n", " - Relative productivity of asymptomatic quarantined individuals to asymptomatic non-quarantined individuals. \n", " $$ Y_t = M_t^{A,NQ} + A_{rel}\\times M_t^{A,Q} $$\n", " - If this is lower, then *Common quarantine* policy will lead to larger declines in output relative to *Targeted quarantine* policies.\n", "1. **Disease parameters**\n", " - Number of initial infections in the US population\n", " - $\\pi^D$ \n", " - Rate at which *symptomatic* individuals die from the virus.\n", "1. **Timing parameters**\n", " - Date of vaccine - In the paper we set this to 500 days\n", " - $1/\\delta$\n", " - Gives the number of days that it takes, on average, to show symptoms once infected with the virus\n", " - $1/\\omega^R$\n", " - Gives the number of days that it takes, on average, to recover from the virus\n", "1. **Contagion parameters**\n", " - $R_0$\n", " - This is the baseline transmission rate. In the code $\\rho^S$---the probability of infection conditional on meeting---is chosen to imply this level of $R_0$\n", " - $\\rho^A/\\rho^S$\n", " - This is measures the relative infectiousness of asymptomatic individuals. A meeting with a symptomatic individual results in infection with probability $\\rho^S$. If $\\rho^A/\\rho^S=0.5$, then half as many meetings with asymptomatic individuals result in infection. In the paper we simply set this to 1.\n", " \n", "#### 2.2 Policy parameters\n", "\n", "The second set appear in Tables 5 and 6 of the paper, these are the very simply 'policy parameters' $\\tau\\geq 0$ and $\\Delta\\in[0,1]$ which represent the rate of daily testing and the slackening of quarantine measures that we use to construct our counterfactual.\n", "\n", "- Chooses one of the two parameters to *Slide over*\n", "- Set the range for the other parameter. \n", " - When sliding over $\\Delta$, the *upper value* is always 1, which represents no slackening of quarantine. User then chooses the *lower bound*.\n", " - When sliding over $\\tau$, the *lower value* is always 1, which represents no testing. User then chooses the *upper bound*.\n", " - In both cases the grid of parameters that are considered is evenly spaced and has 10 points.\n", "- Proceed as above: Click **[Run model]**, wait until it displays **\"Done solving model\"**, then click **[Show panel chart]**" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n", "# INSTRUCTIONS: Click to place cursor in this box, and then press Ctrl+Enter\n", "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n", "\n", "from IPython.display import Javascript\n", "Javascript(\"Jupyter.notebook.execute_cells([3,4,5,6])\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from model_code import *\n", "from jupyterWidgets import *" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Toggle on/off the raw code\n", "from IPython.display import HTML\n", "\n", "HTML('''\n", "
''')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "display(paramsPanel)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "display(run_box)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "τ_list = np.arange(0., τ_max.value + τ_step.value, τ_step.value)\n", "Δ_list = np.arange(Δ_min.value, 1. + Δ_step.value, Δ_step.value)\n", "if slide_var.value == 1:\n", " f = generate_plots(Δ.value, τ_list, ξ_base.value, A_rel.value, d_vaccine.value*14+3*14, \\\n", " rel_ρ.value, δ_param.value, ωR_param.value, π_D.value, \\\n", " R_0.value, rel_λ.value, initial_infect.value, slide_var.value)\n", "elif slide_var.value == 2:\n", " f = generate_plots(Δ_list, τ.value, ξ_base.value, A_rel.value, d_vaccine.value*14+3*14, \\\n", " rel_ρ.value, δ_param.value, ωR_param.value, π_D.value, \\\n", " R_0.value, rel_λ.value, initial_infect.value, slide_var.value)\n", " \n", "print(\"Done solving model.\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "f\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "