Disease modeling for public health
  • About
  • Blog
  • Publications
Categories
All (142)
Adam (1)
adaptive design (1)
Alembic (1)
algorithmic approach (1)
analysis (4)
apartment (1)
API (3)
API client (1)
API design (1)
Arbitrary-Depth (1)
Arbitrary-Width (1)
architecture (1)
Arrow (1)
async (1)
attention (1)
authentication (1)
automatic differentiation (1)
automation (1)
AWS (4)
backpropagation (1)
Basic reproduction number (2)
Bayesian (2)
Bayesian workflow (2)
billing (1)
branching process (3)
business (2)
business skills (20)
C++ (1)
caching (1)
Celery (1)
censor (2)
ChatGPT (4)
cholera (4)
CI/CD (1)
Claude (1)
clinical trial (4)
cloud (1)
code (4)
compliance (1)
contact (2)
correlate of protection (1)
COVID-19 (2)
critical vaccination threshold (1)
crop (1)
cross-correlation (2)
dashboard (1)
data assimilation (1)
data engineering (2)
data quality (1)
data validation (1)
database (3)
deep learning (9)
density (1)
density-dependent (1)
deployment (2)
deSolve (3)
deterministic (1)
DevOps (4)
diffeqr (2)
differential equation (1)
DifferentialEquations.jl (1)
digital twin (17)
direct (1)
Docker (1)
doParallel (1)
DQN (1)
DuckDB (1)
ecology (1)
emergence (1)
emulator (1)
ensemble (1)
ensemble methods (1)
epidemic (1)
epidemic modeling (3)
epidemiology (6)
Erlang (1)
Erlang distribution (2)
Euler method (1)
evolutionary games (1)
exponential (2)
exponential growth (1)
FastAPI (3)
final epidemic size (2)
Flux (1)
foreach (1)
forecasting (2)
frequency-dependent (1)
game theory (2)
Gamma (1)
Gaussian process (1)
generality (1)
generalized linear model (1)
generation interval (2)
ggplot2 (2)
Gillespie's algorithm (1)
GIS (1)
GitHub Actions (1)
GPT-2 (2)
growth rate (1)
health data (1)
high-frequency (1)
HIPAA (1)
httr (2)
httr2 (1)
idiosyncransy (1)
immunology (2)
importance sampling (1)
incidence (1)
incubation period (1)
indirect (1)
indirect vaccine effectiveness (1)
infectious disease (3)
Infectious diseases (1)
infrastructure as code (1)
interval censoring (3)
isolation (1)
julia (4)
Julia (1)
JWT (1)
Kalman filter (1)
kalman filter (1)
LabelledArrays (1)
Latin hypercube sampling (1)
likelihood ratio (1)
linear model (1)
LLM (2)
logging (1)
Logistic function (1)
machine learning (7)
map (1)
mapping (1)
market (1)
mask (1)
mass action (1)
Mathematica (2)
matrix (1)
maximum likelihood (4)
MCMC (1)
migrations (1)
minimax (1)
MLE (1)
modeling (1)
monitoring (1)
Monte Carlo (1)
multi-tenancy (1)
multinomial (1)
multiscale (1)
muscle (1)
NamedTupleTools (1)
negative binomial (2)
Neural network (2)
neural networks (1)
Neural ODE (1)
news (2)
next generation matrix (1)
nimble (1)
nonlinearity (1)
observability (1)
ODE (10)
odin (2)
operations (1)
optim (1)
optimization (1)
optimize (1)
oral cholera vaccine (1)
overall (1)
overdetermination (1)
paper (1)
parallelism (1)
parameter estimation (5)
Parquet (1)
particle filter (3)
PDE (1)
performance (1)
pharma (1)
PINN (6)
Poisson process (1)
pomp (1)
population immunity (1)
posterior predictive check (1)
PostgreSQL (2)
power analysis (1)
prevalence (1)
pricing (1)
probability of a large outbreak (1)
profile likelihood (5)
prompt engineering (1)
public health (2)
Python (11)
PyTorch (1)
Quarto (1)
quasi-Monte Carlo (1)
R (61)
R Markdown (1)
R package (1)
random forests (1)
raster (2)
RColorBrewer (2)
Rcpp (1)
real-time (1)
Redis (1)
regression (4)
reinforcement learning (1)
reporting (1)
reproducibility (2)
reproduction number (4)
REST (1)
REST API (1)
right truncation (1)
robust decision (1)
SaaS (1)
sarcopenia (1)
SDK (1)
secrets management (1)
security (3)
SEIR (8)
SEIR model (1)
sensitivity analysis (1)
serial interval (3)
sf (3)
shapefile (2)
SIR (6)
SIR model (1)
size (1)
Sobol (2)
social contact (2)
software engineering (7)
spatial epidemiology (1)
Stan (2)
statistics (2)
steady states (1)
stochastic (1)
stock market (2)
Streamlit (1)
Stripe (1)
sub-exponential growth (1)
sub-Saharan Africa (1)
surrogate model (1)
surveillance (1)
SymPy (2)
synthetic control (1)
task queue (1)
Terraform (1)
testing (1)
time series (3)
TimescaleDB (1)
tobit (1)
total (1)
trace plot (1)
transformers (2)
transmission dynamics (1)
trial simulation (1)
UDE (1)
uniroot (1)
Universal Approximation Theorem (1)
universal differential equation (1)
vaccination (2)
vaccine (9)
Vaccine (1)
vaccine efficacy (2)
vaccine-derived immunity (1)
variable selection (1)
versioning (1)
virtual patients (1)
visualisation (1)
waning (2)
WebSockets (1)
Wolfram (2)
writing (1)
xml (2)
감염병 (1)
수리모형 (1)
역사 (1)
역학 (1)

Spatiotemporal PINNs: Disease Spread as a Reaction-Diffusion System

PINN
PDE
epidemiology
Python
deep learning
The previous posts in this series worked with compartmental ODEs — dynamics in time alone. Real epidemics have spatial structure: disease spreads outward from index cases…
Apr 25, 2026
19 min

API Versioning Strategies for Long-Running Client Integrations

business skills
API design
versioning
REST
software engineering
A hospital surveillance team has written an automated pipeline that calls your /simulate endpoint every night. You add a new field delta_I to the response — a breaking…
Apr 24, 2026
5 min

Securing Your API with JWT Authentication and Role-Based Access

business skills
security
authentication
JWT
FastAPI
R
Your epidemic model API is live. Without authentication, anyone who discovers the URL can call /simulate without limit, read your clients’ outbreak data, and flood the…
Apr 24, 2026
8 min

Usage-Based Billing: Metering API Calls and Compute

business skills
billing
pricing
Stripe
SaaS
R
You sign a contract with a health department for $2,000/month. A year in, you realise one client is running 5× more EnKF jobs than any other — and consuming 60% of your…
Apr 24, 2026
6 min

Caching Surrogate Model Outputs for Sub-Second API Responses

business skills
caching
Redis
performance
R
An analyst opens your dashboard and selects “Run scenario: 30% transmission reduction for district_a”. Your system runs the surrogate model, queries TimescaleDB, formats the…
Apr 24, 2026
6 min

Automated Testing and CI/CD Pipelines for Epidemic Models

business skills
CI/CD
testing
GitHub Actions
R
A client’s health department runs your epidemic model every morning to inform a 9 AM briefing. On Tuesday, a routine parameter update silently changes the outbreak peak by…
Apr 24, 2026
7 min

HIPAA-Aware Architecture Patterns for Health Data on AWS

business skills
HIPAA
compliance
AWS
security
health data
The Health Insurance Portability and Accountability Act (1) governs Protected Health Information (PHI) in the United States. If your digital twin processes surveillance data…
Apr 24, 2026
6 min

A Lightweight Data Lake for Epidemic Surveillance Ingestion

business skills
data engineering
Parquet
DuckDB
Arrow
R
A real-time epidemic digital twin ingests from multiple sources simultaneously:
Apr 24, 2026
6 min

Data Validation: Catching Bad Surveillance Data Before It Corrupts Your Model

business skills
data validation
data quality
R
surveillance
The EnKF from Post 4 receives daily case counts and updates its state estimate. What happens when the surveillance system sends a negative count (database export error), a…
Apr 24, 2026
6 min

Database Schema Migrations for Production TimescaleDB

business skills
database
migrations
Alembic
PostgreSQL
DevOps
Your digital twin has been running in production for two months. You want to add a severity_level column to the model_states table — a field that did not exist when the…
Apr 24, 2026
6 min

Spatial Epidemiology: Mapping Disease Burden and Transmission Corridors

business skills
spatial epidemiology
GIS
mapping
R
A client health department’s jurisdiction contains 20 districts. Two are doing fine; three are accelerating rapidly; one has already peaked. A single aggregate model hides…
Apr 24, 2026
6 min

Infrastructure as Code: Reproducible AWS Environments with Terraform

business skills
infrastructure as code
Terraform
AWS
DevOps
You spend two days clicking through the AWS console to configure an EC2 instance, install Docker, set up TimescaleDB, and configure the load balancer. It works perfectly.…
Apr 24, 2026
6 min

Hybrid Forecasting: Combining Mechanistic Models with Machine Learning

business skills
forecasting
machine learning
ensemble
R
Mechanistic SEIR models are powerful at long horizons (4–12 weeks) because they encode biological constraints: the epidemic cannot grow faster than \(R_0\) allows, and it…
Apr 24, 2026
7 min

Observability for Digital Twin Services: Logging, Metrics, and Alerting

business skills
monitoring
logging
observability
operations
Your EnKF runner is scheduled for 2 AM. At 6 AM your client’s epidemiologist logs in and the dashboard shows stale data. Was it a database connection failure? A malformed…
Apr 24, 2026
8 min

Multi-Tenant Architecture: Serving Multiple Health Departments on One Platform

business skills
multi-tenancy
database
architecture
software engineering
Your first client is running on a dedicated instance — one database, one API container. You sign a second client. Do you:
Apr 24, 2026
6 min

Async Task Queues for Long-Running Simulation Jobs

business skills
task queue
async
Celery
R
software engineering
An analyst submits a request to run a 500-particle EnKF over 90 days with 50 scenario iterations. Your FastAPI handler calls the R model and waits. After 90 seconds, the…
Apr 24, 2026
7 min

Automated Parameterized Reports for Epidemic Scenario Outputs

business skills
reporting
Quarto
R Markdown
automation
R
Every Monday morning, your client’s epidemiologist needs a briefing document: current outbreak status, 14-day forecast, and comparison to last week. You could spend 90…
Apr 24, 2026
6 min

Publishing an R Client SDK for Your Digital Twin API

business skills
R package
SDK
httr2
API client
R
Your FastAPI service works. A district epidemiologist wants to use it from their weekly R script. Without an SDK they write:
Apr 24, 2026
6 min

Secrets Management: Keeping Credentials Out of Your Code

business skills
security
secrets management
AWS
DevOps
A developer pushes a database connection string to a public GitHub repository by accident. Within 15 minutes, a bot discovers it and begins exfiltrating patient data. This…
Apr 24, 2026
4 min

Global Sensitivity Analysis as a Billable Model Audit Service

business skills
sensitivity analysis
Sobol
epidemic modeling
R
A health department client asks: “You say \(R_0 = 1.8\), but how sensitive is your 14-day forecast to that estimate? What if it’s actually 2.2?” Without sensitivity analysis…
Apr 24, 2026
7 min

Real-Time Simulation Progress Streaming with WebSockets

business skills
WebSockets
real-time
FastAPI
R
API
A standard HTTP request has a request–response cycle: client asks, server computes, server replies. If the computation takes 30 seconds, the client waits with a blank…
Apr 24, 2026
7 min

Self-Attention and Transformers: The Architecture Behind LLMs

machine learning
transformers
attention
deep learning
R
“Attention Is All You Need” by Vaswani et al. (1) is likely the most cited paper in the field of deep learning. It introduced the transformer architecture, which rendered…
Apr 24, 2026
9 min

Gradient Descent: The Optimization Engine Behind Every ML Model

machine learning
optimization
R
epidemic modeling
Every machine learning algorithm — from linear regression to GPT-4 — is doing the same thing: finding parameter values that minimize a loss function. The loss measures how…
Apr 24, 2026
7 min

Using LLMs in Production: Automated Epidemic Intelligence Reports

machine learning
LLM
prompt engineering
API
public health
R
Your digital twin produces R-effective estimates, 30-day case forecasts, and intervention scenarios — but the output is a dataframe. The epidemiologist at a health…
Apr 24, 2026
7 min

Neural Networks from Scratch: Build and Train One in Pure R

machine learning
neural networks
deep learning
R
Neural networks are the backbone of modern ML — image classifiers, language models, and surrogate epidemic simulators all use the same underlying mechanism. Most tutorials…
Apr 24, 2026
7 min

Random Forests: Ensemble Learning for Outbreak Risk Scoring

machine learning
random forests
ensemble methods
R
public health
Epidemic risk scoring — flagging districts that are likely to see an outbreak — is a classification problem on tabular data: vaccination coverage, population density, age…
Apr 24, 2026
5 min

Neural ODEs and Universal Differential Equations

PINN
Neural ODE
UDE
Python
deep learning
The previous posts in this series trained a network to map time directly to compartment values, penalising ODE violations through the physics loss. There is a fundamentally…
Apr 24, 2026
17 min

Deploying a Digital Twin to the Cloud

digital twin
software engineering
AWS
cloud
deployment
DevOps
The Docker container from Post 3 runs on your laptop. The TimescaleDB instance from Post 6 persists data locally. Neither is accessible to a partner organisation in another…
Apr 23, 2026
8 min

Building a Real-Time Dashboard with Streamlit

digital twin
dashboard
Streamlit
Python
visualisation
The digital twin stack built across Posts 1–7 now runs entirely on AWS:
Apr 23, 2026
11 min

Time-Series Data Storage with TimescaleDB

digital twin
database
TimescaleDB
PostgreSQL
R
data engineering
After Post 4 (EnKF) and Post 5 (GP surrogate), your digital twin produces several types of time-stamped output every day:
Apr 23, 2026
12 min

Containerising Your Model Service with Docker

digital twin
software engineering
Docker
deployment
reproducibility
In Post 2 we built an epidemic model API. It runs on your laptop with uvicorn sir_api.main:app. To share it with a colleague you send them your code and they spend an…
Apr 23, 2026
7 min

Real-Time State Estimation with the Ensemble Kalman Filter

digital twin
Kalman filter
data assimilation
R
epidemic modeling
An epidemic model fed fixed parameters produces a single trajectory. A digital twin does something more: it continuously updates its internal state as real data arrive, so…
Apr 23, 2026
15 min

Exposing Your Epidemic Model as a REST API

digital twin
software engineering
Python
FastAPI
REST API
In Post 1 we built a validated, testable SIR model function. That function can be called from R or Python by anyone who installs your package. But “install my package” is a…
Apr 23, 2026
12 min

The Production Gap: From Research Code to Software Product

digital twin
software engineering
Python
R
reproducibility
You have built an epidemic model that works. It fits data, recovers parameters, and produces credible forecasts. You have written it carefully in R or Python, and the…
Apr 23, 2026
11 min

Surrogate Models: Replacing Slow Simulations with Fast Emulators

digital twin
Gaussian process
surrogate model
emulator
R
The Ensemble Kalman Filter in Post 4 ran 300 particles through an SEIR model 90 times — around 27,000 model evaluations. For a compartmental ODE with five states, each…
Apr 23, 2026
13 min

Transformer-Based LLM Architectures for Epidemic Time Series Forecasting

machine learning
transformers
time series
forecasting
R
The previous post showed that attention is a learned weighted average over a context window. That is the mechanism inside every LLM — GPT, Claude, Gemini — and it also…
Apr 23, 2026
16 min

PINNs for SEIR: Learning Time-Varying Transmission

PINN
SEIR
epidemiology
Python
deep learning
The SIR PINN tutorial recovered a constant transmission rate \(\beta\) from noisy prevalence data. Real outbreaks are messier in two important ways.
Apr 23, 2026
16 min

The Business of Digital Twins in Drug Development

digital twin
vaccine
clinical trial
business
market
pharma
Over five technical posts we built a complete digital-twin pipeline for vaccine clinical trials:
Apr 22, 2026
11 min

Correlates of Protection

digital twin
vaccine
correlate of protection
immunology
R
Post 1 built a within-host ODE model that predicts the antibody titre trajectory \(\text{Ab}(t)\) for a vaccinated individual. We can run that model for any individual whose…
Apr 22, 2026
18 min

Multiscale Modelling for Digital Twins in Vaccine Trials

digital twin
multiscale
ODE
R
vaccine
infectious disease
The outcome of a vaccine trial depends on processes that span at least three orders of magnitude in time and space: molecular events inside a single cell, the kinetics of an…
Apr 22, 2026
13 min

Muscle Digital Twins: Science, Opportunity, and Directions

digital twin
muscle
ODE
R
sarcopenia
business
Skeletal muscle is one of the most tractable organs for digital-twin modelling. Its adaptation to mechanical loading follows dose–response kinetics that can be written down…
Apr 22, 2026
16 min

Synthetic Control Arms

digital twin
vaccine
synthetic control
clinical trial
Bayesian
R
Clinical trials use randomisation to ensure that, on average, the treatment and placebo groups are comparable at baseline. This is a powerful guarantee: if subjects are…
Apr 22, 2026
15 min

Adaptive Trial Design with Digital Twins

digital twin
vaccine
adaptive design
trial simulation
power analysis
R
Trial design has always involved simulation. The classical approach uses algebraic power formulas: given assumed effect size, variance, and type I and II error rates, solve…
Apr 22, 2026
19 min

Building Virtual Patient Cohorts

digital twin
vaccine
virtual patients
Latin hypercube sampling
Sobol
quasi-Monte Carlo
R
Post 1 built an ODE model of vaccine-induced immunity for a single individual. Post 2 showed how to convert an antibody trajectory into a protection probability at each…
Apr 22, 2026
32 min

Within-Host Dynamics of Vaccine-Induced Immunity

digital twin
vaccine
immunology
ODE
R
The previous post introduced digital twins for clinical trials at a high level. A vaccine digital twin is, at its core, a model that takes one patient’s characteristics as…
Apr 22, 2026
15 min

Digital Twins in Clinical Trials

digital twin
clinical trial
vaccine
infectious disease
R
The term digital twin was coined by Michael Grieves around 2002 in a manufacturing context: a real artefact, a virtual replica that mirrors it, and a bidirectional data…
Apr 21, 2026
13 min

Understanding Automatic Differentiation

automatic differentiation
deep learning
PINN
backpropagation
Python
In my previous post on Physics-Informed Neural Networks, the SIR residual was computed with a single line:
Apr 20, 2026
24 min

Minimax: Planning for the Worst-Case Epidemic

game theory
minimax
robust decision
vaccination
cholera
R
The vaccination game was a game between people. Each individual weighed the cost of vaccination against the risk of infection, and the Nash equilibrium emerged from their…
Apr 20, 2026
16 min

Game Theory for Infectious Disease Modeling

game theory
vaccination
SIR
epidemiology
R
evolutionary games
Part 1 of a 5-part series on game theory for theoretical epidemiologists. The goal is not a comprehensive textbook but a working vocabulary, a few canonical examples, and a…
Apr 20, 2026
13 min

Reinforcement Learning for Epidemic Control

reinforcement learning
DQN
SIR
epidemiology
Python
deep learning
Reinforcement learning (RL) addresses a deceptively simple problem: an agent interacts with an environment by selecting actions, observing the resulting state, and receiving…
Apr 14, 2026
17 min

Bayesian Physics-Informed Neural Networks

PINN
SIR
Bayesian
PyTorch
deep learning
The SIR PINN tutorial recovered point estimates of \(\beta\) and \(\gamma\). Here we exlore the distribution of \(\beta\) consistent with these data.
Apr 11, 2026
29 min

Physics-Informed Neural Networks for Epidemic Modeling

PINN
SIR
epidemiology
Python
deep learning
The idea of using neural networks to solve differential equations predates deep learning. Lagaris et al. (1) showed in 1998 that a simple feedforward network, trained to…
Apr 9, 2026
13 min

High-Frequency Lead-Lag Effects in Stock Markets

statistics
stock market
Python
cross-correlation
time series
high-frequency
In the previous post we saw that lag effects in daily stock returns are generally weak — a finding consistent with the efficient market hypothesis. But zoom in to 1–5 minute…
Mar 15, 2026
15 min

Cross-Correlation in Stock Market Data

statistics
stock market
Python
cross-correlation
time series
When we study multiple stock prices together, one of the first questions is: do they move together, and if so, by how much and with what delay? Cross-correlation answers…
Mar 14, 2026
13 min

How many infections does one isolation prevent?

epidemiology
branching process
isolation
overdetermination
When a newly infected person successfully isolates, how many downstream infections does that prevent? The answer depends on the structure of transmission — not just the…
Mar 10, 2026
13 min

Heterogeneous Risk and Targeting Accuracy in Vaccination Allocation

We extend the homogeneous risk model to a heterogeneous risk setting where the outbreak probability \(x\) varies across the population according to a probability density…
Mar 9, 2026
50 min

To Wait or To Act? Optimizing Reactive vs. Pre-emptive Vaccination Strategies

Preventing and controlling infectious disease outbreaks requires making strategic use of limited vaccine stockpiles. This challenge is especially acute for diseases such as…
Mar 9, 2026
79 min

Simulating Correlated Outbreak Parameters Using Copulas

I wanted to simulate synthetic outbreaks based on realistic distributions for the following three parameters:
Jul 25, 2025
7 min

Outbreak Simulation: Pre-emptive vs. Reactive Vaccination

When managing infectious disease risks such as cholera, limited vaccine supply often forces decision-makers to choose between pre-emptive and reactive vaccination campaigns.…
Jun 28, 2025
4 min

다니엘 베르누이의 천연두 연구: 최초의 감염병 수리모형

감염병
수리모형
역학
역사
18세기 유럽은 천연두(smallpox)의 그림자 아래 살고 있었다. 이 무서운 질병은 매년 수십만 명의 목숨을 앗아갔으며, 생존자들에게는 평생 지울 수 없는 흉터를 남겼다 (Razzell, 1977). 이런 상황에서 한 수학자가 수학적 사고를 통해 이 질병에 맞서고자 했다. 그의 이름은 다니엘…
May 6, 2025
6 min

왜 수학으로 감염병을 설명하는가?

수학은 세상을 설명하는 언어다. 바이러스는 숫자를 모른다. 바이러스 어떤 수식을 계산해서 다음 날 환자수를 결정하지는 않을 것이다. 그런데 우리는 바이러스의 전파 과정을 숫자로 설명한다. 왜 그럴까?
Apr 18, 2025
4 min

The Ross-Macdonald Framework: Foundational Mathematical Models in Vector-Borne Disease Epidemiology

The mathematical modeling of infectious diseases has become an indispensable tool in modern epidemiology, guiding intervention strategies and policy decisions. While…
Apr 17, 2025
10 min

The Birth of Epidemic Modeling: Daniel Bernoulli and the Smallpox Inoculation Controversy

Mathematical modeling of infectious diseases is now a cornerstone of public health decision-making. During COVID-19, we all became familiar with concepts like “flattening…
Apr 14, 2025
7 min

Regularization in statistical models

Regularization is a fundamental technique in statistical modeling that helps prevent overfitting and improves model generalization. This blog post explores different…
Feb 2, 2025
4 min

Understanding correlation, covariation, and least squares regression

Understanding relationships between variables is a fundamental aspect of statistical analysis. Three key concepts in this domain are correlation, covariation, and least…
Jan 30, 2025
3 min

Distribution Matching Methods: From Theory to Practice

When working with data from different sources or distributions, we often need to transform one distribution to match another. In this post, we’ll explore various methods for…
Oct 31, 2024
7 min

Bayesian workflow: fake social contact data example

Bayesian workflow
negative binomial
social contact
This post is my attempt to follow along a Bayesian Workflow by Gelman et al and create examples for better understanding. While my ultimate goal is to study infectious…
Jul 21, 2024
12 min

Modeling human behavior: Infectious disease transmission modeling perspective

Bayesian workflow
negative binomial
social contact
감염병의 전파 양상을 연구하는 감염병 역학 (Epidemiology of Infectious Diseases ; EID)에서는 감염병의 발생 양샹을 세 가지 요소로 해석하고자 한다. 하나는 병을 일으키는 감염원 (infectious agent)이고, 다른 하나는 사람이 살아가고 있는 주변 환경…
Jul 21, 2024
1 min

Kalman filter to estimate R using the FKF package

kalman filter
Arroyo-Marioli et al used a Kalman filter approach to estimate. I tried to reproduce in R. Let’s use a SIR model as was used in my previous post to generate growth rate time…
Jul 11, 2024
5 min

Learning ChatGPT 4: Universal Approximation Theorem

Universal Approximation Theorem
Neural network
Arbitrary-Width
Arbitrary-Depth
Neural networks can approximate any function according to the Universal Approximation Theorem. A more precise statement of the theorem is that neural networks with a single…
Jun 24, 2024
3 min

Parallel simulation in R

parallelism
foreach
doParallel
I find that parallel, doParallel and foreach packages provide the easiest approach for parallel computing in R. The doParallel vignette provides a great overview. library(doP…
Jun 14, 2024
2 min

Basic reproduction number: An algorithmic approach

Basic reproduction number
Mathematica
algorithmic approach
next generation matrix
A recent article (1) published in Mathematics discusses an approach to calculating \(\mathcal{R}_0\). Since I have previously written a post about calculating \(\mathcal{R}_0…
Jun 2, 2024
5 min

Claude 3

LLM
Claude
Testing Claude 3 with R
May 30, 2024
2 min

Learning ChatGPT 2: Approximating a tower function using a neural net

Neural network
Adam
matrix
The blog post by Stephen Wolfram discusses a neural network for approximating some sort of a step function. This post is my attempt to reproduce it. A YouTube video and a boo…
May 28, 2024
3 min

A very basic implementation of a neural network

GPT-2
ChatGPT
Wolfram
I am documenting my learning of a neural network. The contents are mostly based on the e-book by Keydana (1). Neural networks have become the foundation of modern deep…
May 27, 2024
3 min

Variables selection in statistical models

R
variable selection
generalized linear model
When building statistical models, one of the most critical steps is variable selection. This process involves choosing the appropriate predictors or features that will be…
May 18, 2024
4 min

Learning ChatGPT 1: Probabilities for the next word

GPT-2
ChatGPT
Wolfram
Inspired by the blog post by Stephen Wolfram about the workings of the GPT-2 system, I decided to learn a bit about ChatGPT myself. Luckily, GPT-2 is now available for R. My…
May 1, 2024
3 min

Logistic function in R

Logistic function
indirect vaccine effectiveness
oral cholera vaccine
The logistic function, represented as: \[ f(x) = \frac{L}{1+e^{-k(x-x_0)}} \] , where \(x_{0}, L\), and \(k\) represent tht value of the function’s midpoint, the supremum of…
Apr 19, 2024
6 min

Waning vaccine efficacy on susceptibility

Vaccine
waning
SEIR
Erlang distribution
In this article, I examined the process of modifying the disease transmission model (for instance, the \(SEIR\) model) to include vaccination and the waning of…
Apr 8, 2024
11 min

SEIR model with varying number of compartments

SEIR
Erlang distribution
The \(SEIR\) model structures each stage as a distinct compartment, with transitions between compartments dictated by specific rate constants, except for the transition…
Apr 5, 2024
5 min

Waning of vaccine effectiveness

vaccine efficacy
clinical trial
SEIR
The protection derived from vaccination often wanes over time and require the second or the third doses (so-called booster doses). For example, the study showed the efficacy…
Apr 4, 2024
7 min

Solutions for the steady states of the SEIR model

SEIR model
steady states
ODE
deSolve
Mathematica
In this post, I compared the numerical solutions obtained using deSolve::ode with the algebraic solutions derived from Mathematica for the steady states of a SEIR model. The…
Mar 28, 2024
10 min

Vaccine effectiveness

SEIR
vaccine efficacy
direct
indirect
total
overall
Vaccine efficacy and effectiveness (VE) is generally estimated as one minus some measure of relative risk (RR) in the vaccinated group compared to the unvaccinated group Hall…
Mar 26, 2024
5 min

Counterintuitive effects in disease transmission dynamics

Infectious diseases
nonlinearity
transmission dynamics
An article by Heesterbeek et al. (1) provides a few examples on the counterintuitive behavior of a dynamical system of disease transmission. The first example was about the…
Mar 20, 2024
1 min

Prevalence vs. incidence for the SIR model

R
prevalence
incidence
deSolve
In the following, I implemented a simple model of disease incidence and recovery. Susceptibles are infected at a constant rate, go through the natural history of infection…
Mar 12, 2024
3 min

감염병의 대유행 가능성

probability of a large outbreak
reproduction number
감염병 인류 라는 책을 재미있게 읽는 중이다. 136페이지에는 기초감염재생산지수와 대유행의 가능성에 대한 간단한 수식이 나온다. \[\text{대유행의 가능성} = 1 - \frac{1}{R_0}\]
Mar 4, 2024
4 min

Modeling the waning of the vaccine-derived immunity in the ODE model

vaccine-derived immunity
waning
cholera
ODE
exponential
Gamma
The use of ordinary differential equation (ODE) models to simulate disease spread and evaluate vaccine impact is growing. Waning of vaccine-derived immunity often follows an…
Feb 27, 2024
10 min

Incremental Cost-Effectiveness Ratio (ICER)

cholera
sub-Saharan Africa
The Incremental Cost-Effectiveness Ratio (ICER) is a crucial metric in health economics, offering insights into the value of medical interventions by comparing their costs…
Feb 25, 2024
5 min

Implementing incubation period of cholera in the ODE model

incubation period
ODE
cholera
exponential
Erlang
In the realm of infectious disease modeling, accurately simulating the incubation period–the time between exposure to a pathogen and the onset of symptoms–is crucial for…
Feb 22, 2024
3 min

Mass-action assumption: density- vs. frequency-dependent transmission

mass action
frequency-dependent
density-dependent
In models of transmission of directly transmitted pathogens, e.g., COVID-19, the transmission is assumed to occur via so-called mass action principle. It means the rate of…
Feb 19, 2024
3 min

LabelledArrays and NamedTupleTools make it easy to use the ODE model in Julia

julia
ODE
LabelledArrays
NamedTupleTools
SEIR
The LabelledArrays package makes it easy to use the ODE model in Julia. It offers a method to manage variables via keys instead of indices. Variables can be constructed…
Jan 26, 2024
2 min

SIR model benchmarks: deSolve, odin, and diffeqr

ODE
R
deSolve
odin
diffeqr
C++
Julia
This post benchmarks three approaches to solving ODE-based SIR models: the deSolve package (1) in R, the odin package (2), and diffeqr which calls Julia…
Jan 19, 2024
5 min

diffeqr: R interface to the Julia’s DifferentialEquations.jl

differential equation
julia
DifferentialEquations.jl
diffeqr
Julia DifferentialEquations.jl provides an impressive collection of differential equation solvers. The DE solvers available in the package are reliable and a lot faster than…
Jan 15, 2024
4 min

Universal differential equation using Julia

universal differential equation
julia
sub-exponential growth
The UDE refers to an approach to embed the machine learning into differential equations. The resulting UDE has some parts of the equation replaced by universal approximators …
Jan 12, 2024
5 min

Fitting a straight line in Julia: Flux machine learning

julia
Flux
linear model
This post is my attempt to learn machine learning in Julia. The contents of this page came from the Flux. Flux is a machine learning package written in Julia.
Jan 4, 2024
1 min

Critical vaccination threshold

vaccine
population immunity
critical vaccination threshold
The following article by Fine provides a great introduction to the critical vaccination threshold.
Dec 14, 2023
4 min

Generation interval

generation interval
reproduction number
Although not published, I wrote a correspondence to Lancet to commenting the article. In the article, the authors stated that the generation interval is the sum of the…
Dec 7, 2023
8 min

Generation interval, growth rate, reproduction number

generation interval
growth rate
reproduction number
Wallinga and Lipsitch wrote a highly cited paper about the reproduction number. It discusses how to derive reproduction number, \(R\), given the growth rate, \(r\), and the…
Dec 6, 2023
3 min

Convolution

particle filter
The following content was adapted from Grant Sanderson’s YouTube video and the Wikipedia article.
Dec 5, 2023
2 min

Idiosyncrasies and generalities

ecology
idiosyncransy
generality
COVID-19
Debates in the population ecology have been categorized by Bjørnstad and Grenfell (1).
Dec 4, 2023
2 min

SIR model in Stan: Euler method

R
Stan
Euler method
SIR model
I developed a SIR model (1) and solved it using an Euler method, then generated fake data as a sequence of noisy observations of daily incidence. Stan (2) is used for…
Nov 28, 2023
6 min

Estimating a time-to-event distribution in Stan

news
code
analysis
This post extends the right-truncation approach from the previous post (see Seaman et al. (1)) by implementing the likelihood in Stan (2), a probabilistic programming…
Nov 24, 2023
6 min

Estimating a time-to-event distribution from right-truncated data

right truncation
exponential growth
Poisson process
Seaman et al. (1) write: Data on time to an event are said to be right truncated if they come from a set of individuals who have been randomly sampled from a population…
Nov 23, 2023
5 min

Estimating serial interval: doubly interval-censored data

R
serial interval
interval censoring
We start simple. Our task is to estimate parameters of a probability density function used to model the serial interval. Suppose dates of onsets of infectors, \(A\), and…
Nov 17, 2023
3 min

Estimating serial interval for a growing epidemic

R
serial interval
interval censoring
When estimating serial intervals or other time-to-event distributions from epidemic data, right truncation is a key consideration: individuals are observed only if their…
Nov 17, 2023
2 min

Estimating serial interval: interval cenoring

R
serial interval
interval censoring
MLE
Suppose dates of onsets of infectors, \(t^{A}\), and infectees, \(t^{B}\), are given as specific dates. Then the likelihood function for the serial interval may be written…
Nov 15, 2023
2 min

Branching process model 2

R
branching process
final epidemic size
In the branching process model, the number of secondary infections is realized as a random number (e.g., Poission or Negative binomial).
Nov 14, 2023
2 min

Final epidemic size: uniroot vs. optimize

epidemic
size
R
uniroot
optimize
Miller (1) shows that the final size of an epidemic for a well-mixed population can be derived in the following way. We divide the population into susceptible, infected, and…
Nov 10, 2023
2 min

SEIR model

SEIR
deterministic
stochastic
Gillespie's algorithm
SEIR 모형은 잠복기가 어느 정도 긴 감염병 (예를 들어 코로나19)의 전파를 모형하는 데 사용한다. 이번 포스트에서는 SEIR 모형을 만드는 방법을 알아본다. 결정론적 (deterministic) 그리고 확률론적 (stochastic) 방법으로 SEIR 모형을 R언어로 만들어 본다.
Nov 9, 2023
8 min

Branching process model

R
branching process
final epidemic size
In the branching process model, the number of secondary infections is realized as a random number (e.g., Poission or Negative binomial).
Nov 8, 2023
3 min

Negative binomial regression with censored data: POLYMOD data

R
regression
contact
censor
This post describes my attempt to reproduce Table 1 of Mossong et al. (1), a landmark study on social contact patterns relevant to infectious disease transmission. Data were…
Nov 2, 2023
9 min

Apartment transactions in Korea via API provided by the Ministry of Land, Infrastructure, and Transport

R
API
apartment
I will plot the price
Nov 1, 2023
2 min

Confidence interval using profile likelihood

SEIR
profile likelihood
likelihood ratio
수리 모형을 이용하여 연구를 하게되면 관찰값을 이용하여 모형의 모수를 보정하는 과정을 거치게 된다. 이 과정을 소위 결과 (관찰값)로 부터 원인 (모형)을 알아내는 과정이라 하여 inverse problem 이라 부르기도 한다. 이 글에서는 \(SEIR\) 모형과 중국 우한 에서의 초기 코로나-19 발열자…
Oct 19, 2023
4 min

SIR model using SymPy

SIR
SymPy
I attempted to replicate some of the simple analytical results presented in the book, Mathematical Epidemiology by Brauer et al.
Oct 16, 2023
1 min

Regression with censored data: AER::tobit and optim

R
regression
censor
tobit
The following example was adapted from the Tobit model in Model Estimation by Example. The dataset contains 200 observations. The academic aptitude variable is apt, the…
Oct 15, 2023
4 min

Mulitple regression: POLYMOD data

R
regression
contact
This post describes my attempt to reproduce Table 1 of the POLYMOD study (1), which is a large European study on social contacts and mixing patterns relevant to the spread…
Oct 12, 2023
3 min

Regression using optim

R
optim
regression
I will use the cars data with give the speed of cars and the distances taken to stop.
Oct 11, 2023
2 min

Extract raster based on a polygon

R
raster
shapefile
crop
mask
sf
raster 이미지의 일부를 추출해보자. 특히, shapefile에 담겨져 있는 polygon에 해당하는 raster 를 추출해보자. raster 패키지의 crop 과 mask 함수를 이용할 수 있다.
Sep 23, 2023
1 min

odin package

ODE
R
odin
이번 Vaccine Impact Modeling Consortium (VIMC) 연례회의에서 odin (1) 이라는 패키지에 대해 알게 되었다. deSolve (2) 의 업그레이드 버전이라고 보면 될까? R 코드를 C언어로 컴파일하기 때문에 최종 모형의 구동속도가 빠르다. 따라서 모형을 여러번 돌려야 하는…
Sep 15, 2023
2 min

PubMed search, ChatGPT summary, and sending an email in Python

ChatGPT
R
xml
httr
Sep 1, 2023
2 min

PubMed search, ChatGPT summary, and sending an email in R

ChatGPT
R
xml
httr
  • Search the PubMed database Use the entrez_search function from the rentrez package to search the PubMed database
  • Sep 1, 2023
    5 min

    Polygon 면적 구하기: sf 와 raster 패키지

    R
    shapefile
    ggplot2
    sf
    raster
    RColorBrewer
    shapefile에 담겨져 있는 polygon의 면적을 구해보자 raster 패키지의 area 혹은 sf 패키지의 st_area 함수를 이용할 수 있다.
    Aug 30, 2023
    1 min

    ggplot2로 지도 그리기

    R
    map
    ggplot2
    sf
    RColorBrewer
    ggplot2를 이용하여 지도 그리기를 해보자. 지도는 shapefile에 담겨져 있다고 가정하자. shapefile을 읽는 방법은 여러가지가 있을 수 있는데 sf 패키지의 st_read 혹은 read_sf 함수를 이용한 후 ggplot2의 geom_sf를 이용하여 그리는 것이 가장 쉬운 것 같다.
    Aug 30, 2023
    2 min

    Writing a paper: Start with an outline

    writing
    paper
    연구자의 업무 중에 연구 만큼 중요한 것이 글쓰기, 특히 논문 쓰기이다. 논문으로 쓰여지지 못한 연구는 타인에게는 존재하지 않는 것이나 다름 없는 것이다.. Whitesides의 논문 (1) 에 논문 쓰기에 유용한 팁이 있어 여기에 기록으로 남긴다. 한 마디로 요약하면 outline (개요)을 이용하는…
    Aug 30, 2023
    1 min

    Importance sampling

    importance sampling
    Importance sampling is a Monte Carlo method for evaluating properties of a particular distribution, while only having samples generated from a different distribution than…
    Aug 30, 2023
    2 min

    Important figures from the book, How to avoid a climate diaster? by Bill Gates

    parameter estimation
    R
    maximum likelihood
    profile likelihood
    How to Avoid a Climate Disaster: The Solutions We Have and the Breakthroughs We Need by Bill Gates is a comprehensive and accessible guide on how to tackle the urgent issue…
    Aug 28, 2023
    2 min

    Regression toward the mean

    parameter estimation
    R
    maximum likelihood
    profile likelihood
    In his lecture, Joseph Blitzstein talks about two basic statistical phenomena: Regression toward to the mean (RTTM) and survivor bias (or conditioning more broadly). The…
    Aug 25, 2023
    4 min

    Survivor bias

    parameter estimation
    R
    maximum likelihood
    profile likelihood
    In his lecture titled “The Soul of statistics” Joseph Blitzstein talks about a survivor bias (or conditioning more broadly) Dr. Derek Muller also talks about various…
    Aug 25, 2023
    3 min

    Estimating the instantaneous reproduction number using the particle filter

    particle filter
    COVID-19
    파티클 필터 (particle filter) 를 이용하여 잠재 변수 (latent variable)를 추정하는 과정을 지난 글에서 다루었다. 관찰값들이 코로나 19 일별 감염자일때 감염병 수리 모형을 이용하여 일별 감염재생산지수 (\((R_t\)) 를 추정한다. 아래 글은 Kucharski et al. (1) …
    Aug 19, 2023
    12 min

    Maximum Likelihood and Profile Likelihood for the SEIR model

    parameter estimation
    R
    maximum likelihood
    profile likelihood
    통계학은 많은 부분 확률모형의 모수를 추정하는 (inferential statistics) 과정이고 모수 추정방법으로 가장 많이 사용되는 방법이 maximum likelihood (ML)이다. 이번 포스트는 2014년 출간된 Cole et al.의 Maximum Likelihood, Profile…
    Aug 14, 2023
    2 min

    Basic reproduction number using SymPy

    Basic reproduction number
    SymPy
    감염병의 전파를 이해하는 데 있어 가장 기본적인 개념이 재감염지수, 특히 기초재감염지수 (\(\mathcal{R}_0\)) 이다. 재감염지수는 한 명의 감염자로부터 생산되는 평균 후속 감염자의 수를 일컫는데 기초재감염지수는 코로나19의 경우 처럼 인구 집단에 면역력을 가진 사람이 없어 모든 사람이 감염될 수…
    Aug 11, 2023
    3 min

    Population Monte Carlo 파퓰레이션 몬테카를로

    Monte Carlo
    R
    parameter estimation
    code
    analysis
    최근에 파티클필터링 (particle filtering; PF) 방법을 이용하여 \(\mathcal{R}_t\) 추정하는 과정에 대한 논문을 썼다. 그런데, 항상 의문이었던 것은 PF를 조금만 변형하면 감염병 모형의 감염속도 \(\beta=\mathcal{R}_0 \gamma\) 와 같은…
    Aug 10, 2023
    8 min

    Simple mathematical models with very complicated dynamics

    R
    code
    analysis
    Robert M. May Nature Vol. 261 June 10, 1976
    Aug 8, 2023
    2 min

    Sub-exponential growth

    news
    code
    analysis
    대부분의 SIR 모형은 감염병 확산의 메커니즘을 아래와 같은 식으로 표현한다.
    Aug 7, 2023
    6 min

    ODE-based SIR models in Stan

    R
    Stan
    ODE
    SIR
    Stan은 통계 모형 뿐 아니라 ODE 모형을 시물레이션하고 모수를 추정하는 데에도 유용하다. 이 포스팅에서는 일별 감염자 자료가 주어졌을 경우 Stan을 이용하여 SIR 모형의 두 개의 모수 (\(\beta, \gamma\))를 추정하는 과정을 기술하겠다. 먼저 deSolve 패키지 양식을 따라 SIR…
    Aug 6, 2023
    5 min

    감염재생산지수 계산하기

    modeling
    reproduction number
    코로나19에 효과적으로 대응하고자 방역 당국과 연구자들이 코로나19의 전파 양상을 분석한 결과가 뉴스에 종종 보도 되었는데 그 내용 중에 빠지지 않는 것이 감염재생산지수이다. 영어로는 reproduction number (\(\mathcal{R}\)) 로 불리는 데 한 명의 감염자로부터 야기된 후속 감염자의…
    Aug 4, 2023
    4 min

    Particle filter using R

    particle filter
    The following example was adapted from the post in RPubs.
    Jul 19, 2023
    3 min

    Multinomial distribution

    multinomial
    Rcpp
    pomp
    When implementing a model of stochastic disease transmission, one has to deal with a situation in which multiple events are possible. For example, susceptible people may…
    Jun 19, 2023
    3 min

    SEIR model using the Nimble pacakge

    nimble
    MCMC
    posterior predictive check
    trace plot
    감염병 수리 모형을 개발하는 데 있어 가장 근본적인 질문 중 하나는 주어진 관찰값 (시계열)하에서 어떤 모형을 선택하고 그 모수의 값을 어떻게 결정하는가이다. 모형을 선택하는 과정은 따로 다루기로 하고 여기서는 일반적으로 사용되는 감염병 수리 모형 (i.e., SIR)을 사용할 때 모수를 추정하는 과정에…
    Jun 19, 2023
    8 min

    모델과 현실: 수학으로 감염병 확산을 읽다

    수학 모델로 감염병 확산을 예측한다. 현실과 얼마나 맞을까? 코로나19는 이 질문의 정답을 알려줬다.
    Apr 18, 2023
    14 min

    The Model and Reality: Bridging Mathematical Frameworks with Real-World Infectious Disease Dynamics

    As infectious disease modelers, we face a fundamental epistemological question: How can abstract mathematical constructs help us understand and predict the complex dynamics…
    Apr 18, 2023
    6 min

    Origins of major human infectious diseases

    infectious disease
    emergence
    density
    Major human infecious disease are believed to have arisen after agriculture revolutionOrigins of major human infectious diseases. By the way, this emergence of infectious…
    Mar 4, 2023
    2 min
    No matching items