0

I'm simulating a Stochastic Simulation for Epidemiology. How do I simulate it in a discrete time? I managed to obtain for continuous time using the coding below.

library(GillespieSSA)    
parms <- c(beta=0.591,sigma=1/8,gamma=1/7)    
x0 <- c(S=50,E=0,I=1,R=0)    
a <- c("beta*S*I","sigma*E","gamma*I")    
nu <- matrix(c(-1,0,0, 1,-1,0, 0,1,-1, 0,0,1),nrow=4,byrow=TRUE)   
set.seed(12345)    
out <- lapply(X=1:10,FUN=function(x) ssa(x0,a,nu,parms,tf=50)$data)
out

How should I alter the coding to get discrete time? Thanking in advance.

4

1 回答 1

2

Gillespie 算法(参见本文)基本上模拟了连续时间马尔可夫链的轨迹(它是一种离散事件模拟方法)。

从广义上讲,这意味着其中的每个事件out都与一个连续的时间相关联,这是您使用的模拟方法所固有的(即容易更改)。

但是,您可以轻松地找出模型在离散时间点的状态:它是具有更高时间戳的第一个事件之前的模型状态。

示例e_1:您在时间1.932..e_2时间1.999892..e_3时间观察反应事件2.00892..。模型当时t=2.0的状态是事件发生和事件发生的状态。e_2e_3

于 2013-05-06T11:27:38.773 回答