[R] Stochastic SEIR model

Francisco Zagmutt gerifalte28 at hotmail.com
Thu Nov 16 18:11:42 CET 2006


Dear Massimo

This site have some code that may help you to get started. 
http://www.statistik.lmu.de/~hoehle/software/

Also if you want to take an agent-based approach, you may want to take a 
look at the "simecol" package


Regards,

Francisco	


Massimo Fenati wrote:
> Thanks for your fast advises.
> 
> A simple examples of SEIR model is shown below:
> 
> #expample of very simple SEIR model#####
> library(odesolve)
> times<-seq(0,1200,1)
> parms<-c(
> 	b=0.35,		#BETA OR COEFFICIENT OF TRANSMISSION
> 	pl=1/7,		#LATENCY
> 	g=1/21,		#RECOVERY
> 	a=0.05/7	#LETHALITY IN ADULT
> 	)
> xstart<-c(S=100,E=0,I=1,R=0,nn=101)	
> model<-function(t,x,parms){
> S	<-x[1]
> E	<-x[2]
> I	<-x[3]
> R	<-x[4]
> nn	<-x[5]
> 
> with(as.list(parms),{
> dS<--S*b*I/nn
> dE<-S*b*I/nn-E*pl
> dI<-E*pl-I*(a+g)
> dR<-I*g
> dnn<-dS+dE+dI+dR
> 
> list(c(dS,dE,dI,dR,dnn))
> })
> }
> out<-as.data.frame(lsoda(xstart,times,model,parms))
> plot(times,out$S,type="l")
> lines(times,out$E,col="green")
> lines(times,out$I,col="red")
> lines(times,out$R,col="blue")
> #########
> 
> I'd like to vary one or more parameters (with several 
> distribution) for obtaining probabilistic results from the 
> model projections.
> 
> Now I'll try also with winBUGS, but I've never worked with 
> it. I hope..
> 
> Thank you very much.
> 
> Max
> 
> 
> 
> On Thu, 16 Nov 2006 09:26:12 -0500
>   Tamas K Papp <tpapp at Princeton.EDU> wrote:
>> On Thu, Nov 16, 2006 at 02:55:07PM +0100, Massimo Fenati 
>> wrote:
>>> Dear colleagues,
>>> I’m a new R-help user. I’ve read the advertisements 
>>> about 
>>> the good manners and I hope to propose a good question.
>>> I’m using R to build an epidemiological SEIR model based 
>>> on ODEs. The odesolve package is very useful to solve 
>>> deterministic ODE systems but I’d like to perform a 
>>> stochastic simulation based on Markov chain Montecarlo 
>>> methods. I don’t know which packages could be used to do 
>>> it (I tried with "sde" but without results).
>>> Have you some suggestions about useful methods and/or 
>>> function in R for reaching my aim.
>> Hi Max,
>>
>> I don't know what SEIR is.  R has some MCMC packages
>> (RSiteSearch("MCMC") will help you there), but it is 
>> easy to write a
>> Metropolis/Gibbs sampler yourself, making use of the 
>> structure of your
>> problem.
>>
>> The sde package is for approximating likelihoods of 
>> continuous time
>> stochastic differential equations (which is a difficult 
>> problem by
>> itself).
>>
>> It is hard to give more advice without knowing what you 
>> are trying to
>> achieve -- it is good that you have read the posting 
>> guide, but please
>> give more details if you want more specific answers.
>>
>> HTH,
>>
>> Tamas
> 
> MASSIMO FENATI
> -----------------------------------------
> Istituto Nazionale per la Fauna Selvatica
> Via Cà Fornacetta, 9
> 40064 - Ozzano dell'Emilia (BO)- Italy
> tel: +39 0516512245
> cel: +39 3392114911
> fax: +39 051796628
> e-mail: massimo.fenati at infs.it
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

-- 
Dr. Francisco J. Zagmutt
College of Veterinary Medicine and Biomedical Sciences
Colorado State University



More information about the R-help mailing list