Re: [R] Stochastic SEIR model

2006-11-16 Thread Tamas K Papp
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

__
R-help@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.


Re: [R] Stochastic SEIR model

2006-11-16 Thread Paternostro . Amy
Dear Max,

Check out the BUGS software available (free) at
http://www.mrc-bsu.cam.ac.uk/bugs/. It is easy to use and there are
several packages in R which comport with the varying BUGS programs
(R2WinBUGS, bRugs, rbugs, etc.).

Best wishes,
Amy Paternostro

__
R-help@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.


Re: [R] Stochastic SEIR model

2006-11-16 Thread Massimo Fenati
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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED]

__
R-help@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.


Re: [R] Stochastic SEIR model

2006-11-16 Thread Francisco Zagmutt
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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
 
 __
 R-help@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

__
R-help@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.


Re: [R] Stochastic SEIR model

2006-11-16 Thread Ben Bolker

  see also:

http://www.zoo.ufl.edu/bolker/eid/

__
R-help@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.