[R] Stochastic SEIR model
Massimo Fenati
massimo.fenati at infs.it
Thu Nov 16 16:27:08 CET 2006
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 a Princeton.EDU> wrote:
> On Thu, Nov 16, 2006 at 02:55:07PM +0100, Massimo Fenati
>wrote:
>> Dear colleagues,
>> Im a new R-help user. Ive read the advertisements
>>about
>> the good manners and I hope to propose a good question.
>> Im using R to build an epidemiological SEIR model based
>> on ODEs. The odesolve package is very useful to solve
>> deterministic ODE systems but Id like to perform a
>> stochastic simulation based on Markov chain Montecarlo
>> methods. I dont 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 a infs.it
More information about the R-help
mailing list