Skip to content

Instantly share code, notes, and snippets.

@abikoushi
abikoushi / expgrowth_sir.R
Last active May 25, 2026 19:09
SIR/SEIR モデルの初期の指数増加
#reference :
#Junling Ma.(2020).Estimating epidemic exponential growth rate and basic reproduction number,Infectious Disease Modelling,5,129-141.
#https://doi.org/10.1016/j.idm.2019.12.009.
library(deSolve)
library(ggplot2)
library(tidyr)
library(dplyr)
library(patchwork)
@abikoushi
abikoushi / EulerLotka.R
Created May 24, 2026 13:44
基本再生産数と世代時間の関係
#西浦博 他『感染症流行を読み解く数理』(日本評論社)図3.3
library(dplyr)
library(ggplot2)
R0hat_gamma <- function(m,CV){
r <- 0.135
ab2 <- (m*CV)^2
b <- ab2/m
a <- m/b
@abikoushi
abikoushi / NHPP_weibull.R
Created May 20, 2026 16:45
Anime for the point estimation of non-homogenous Poisson process with power-law growth
library(animation)
intensity_weibull <- function(t,alpha, beta){
(beta/alpha)*(t/alpha)^(beta-1)
}
Intensity_weibull <- function(x,alpha,beta){
(x/alpha)^beta
}
@abikoushi
abikoushi / NHPP_exp.R
Last active May 20, 2026 16:46
Anime for the point estimation of non-homogenous Poisson process with exponentially growth
library(animation)
#累積強度関数
Intensity_exp <- function(t, a, b) {
## (exp(a*t+b)-exp(b))/a
exp(b) * expm1(a * t) / a
}
#強度関数
intensity_exp <- function(t,a,b){
library(readr)
library(dplyr)
library(ggplot2)
library(tidyr)
###
#data
#https://www.esri.cao.go.jp/jp/sna/data/data_list/sokuhou/files/2025/qe254_2/gdemenuja.html
###
path <- "./data/GDP/gaku-jk2542.csv"
dat <- read_csv(path, skip = 5, n_max=128)
@abikoushi
abikoushi / nowcasting.md
Created May 12, 2026 05:24
Nowcast-It における Nowcasting の方法論
marp true
theme uncover
style section { font-size: 24px; text-align: left; }
@abikoushi
abikoushi / SEIR.tex
Created May 9, 2026 04:07
DAG using TikZ
%Kucharski A, Russell T, Diamond C et al.
%Early dynamics of transmission and control of COVID-19: a mathematical modelling study
%The Lancet Infectious Diseases, 2020; 20, 553-558
%https://www.thelancet.com/article/S1473-3099(20)30144-4/fulltext
\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta,fit,backgrounds}
\begin{document}
@abikoushi
abikoushi / NSLogis.R
Created May 2, 2026 11:13
Numerical solution and slope field of logistic equation
library(deSolve)
library(ggplot2)
library(tidyr)
library(dplyr)
library(foreach)
library(patchwork)
mod_logistic <- function(Time, State, Pars) {
with(as.list(c(State, Pars)), {
dX <- a*X*(1.0 - X/N)
@abikoushi
abikoushi / SIRmod.R
Created May 2, 2026 02:19
Plot vector field of SIR model
library(deSolve)
library(ggplot2)
library(tidyr)
library(dplyr)
library(foreach)
SIRmod <- function(Time, State, Pars) {
with(as.list(c(State, Pars)), {
dS <- - beta*S*I
dI <- beta*S*I - gamma*I
dR <- gamma*I
@abikoushi
abikoushi / LVmod.R
Created May 1, 2026 14:42
Plot vector field of Lotka-Volterra model
library(deSolve)
library(ggplot2)
library(tidyr)
library(dplyr)
library(foreach)
LVmod <- function(Time, State, Pars) {
with(as.list(c(State, Pars)), {
dPrey <- a*Prey - b*Prey*Predator
dPredator <- -c*Predator + d*Prey*Predator