Hi,
 the following model (realised with deSolve) 
includes four different but connected differential
equations. This example is a simplification
of an disease infection model (S=Susceptible, 
I=Infected, R=Recovered, M=Migrants):

library(deSolve)

mod <- function(t, x, parms){
	with(as.list(c(x,parms)),{
	
	dS <- -b*I*M*S - h*I
	dI <-  b*I*M*S + h*I - r*I
	dR <-          r*I
	
	dM <- 0
	
	res <- c(dS, dI, dR, dM)
	list(res)
	})
}

eventdat <- data.frame(var = c("M", "M"),
                       time = c(100, 200) ,
                       value = c(200, 0),
                       method = c("add", "rep"))



xstart <- c(S=500, I=10, R=0, M=0)
times  <- 1:365
parms  <- c(
		b=0.0005,
		r=0.005,
		h=0.0005
)

tmp <- ode(xstart, times, mod, parms, event=list(data=eventdat))
plot(tmp)



Migrants are leaving and entering
the system and I used events for both processes, however 
this is not really biological. Both events would better
reflect nature if they are following a sigmoidal pattern.

I tried different ways of creating a rate following the area
under a normal distribution which somehow works but
could never delete all Migrants at the end of the year
(for obvious reasons).

Ideally, I would like to give the start and the end of the
process as parameters (arrival or departure and the amount of
Individuals entering the system).

Any ideas are very much appreciated!
Simeon

	[[alternative HTML version deleted]]

