[R-sig-dyn-mod] Individual-based modelling
Sibylle Mohr
Sibylle.Mohr at glasgow.ac.uk
Tue Jul 11 14:22:40 CEST 2017
Dear Jeremy & list members,
I still try to get my head around the individual-based model..
So essentially I have to create a matrix or grid model for the non-spatial metapopulation, right?
See below some code for an SIR matrix model with vaccination.
I’m not quite sure how to integrate the immune response equations / mite shedding into this.
I’d be grateful for any suggestions..
Best wishes & many thanks,
Sibylle
Model code:
n <- 3
S <- rep(99, times=n)
I <- rep(1, times=n)
R <- rep(0, times=n)
state <- c(S, I, R)
sir.vacc.model <- function(t, state, parameters) {
S <- state[1:n]
I <- state[(n+1):(2*n)]
R <- state[(2*n+1):(3*n)]
with (as.list(parameters),{
dS = N*mu*(1-p)-beta*S*I - mu*S
dI = beta*S*I - nu*I - mu*I
dR = nu*I-mu*R+N*mu*p
# return the rate of change
list(c(dS, dI, dR))
})
}
parameters = c(mu=0.01,beta=0.002,nu=0.11)
times=seq(0,365,by=1)
p=0.2
N=100
require(deSolve)
output=ode(y=state,times=times,func=sir.vacc.model,
parms=parameters)
head(output)
par(oma = c(0, 0, 3, 0))
plot(output, xlab = "time", ylab = "-", mfrow=c(3,3))
> On 6 Jul 2017, at 11:00, r-sig-dynamic-models-request at r-project.org wrote:
>
> Send R-sig-dynamic-models mailing list submissions to
> r-sig-dynamic-models at r-project.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models
> or, via email, send a message with subject or body 'help' to
> r-sig-dynamic-models-request at r-project.org
>
> You can reach the person managing the list at
> r-sig-dynamic-models-owner at r-project.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of R-sig-dynamic-models digest..."
>
>
> Today's Topics:
>
> 1. Re: Individual-based modelling (Jeremy Chacon)
> 2. Re: Individual-based modelling (Sibylle Mohr)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 5 Jul 2017 08:50:53 -0500
> From: Jeremy Chacon <chaco001 at umn.edu>
> To: Special Interest Group for Dynamic Simulation Models in R
> <r-sig-dynamic-models at r-project.org>
> Subject: Re: [R-sig-dyn-mod] Individual-based modelling
> Message-ID:
> <CAH65v71sFxkMW8tPVETdCdiJiFA6QE9=atv+4eF7k-udEw24KA at mail.gmail.com>
> Content-Type: text/plain; charset="UTF-8"
>
> Can you give a bit more info on what you mean by extending to a flock?
> That probably affects how to do it. What I think you mean is to consider
> each sheep an individual "island" in the flock which is a sort of
> "archipelago," where the mites can immigrate to and emigrate from different
> sheep with different rates. If this is right, you could look into
> metapopulation modeling. This generally means that each sheep would be
> treated individually, but connected to the other sheep by dispersal of the
> mites. This could all be done with a single system of ODEs, without the
> need for a bigger structure ("two-stage model").
>
> On Mon, Jul 3, 2017 at 6:49 AM, Sibylle Mohr <Sibylle.Mohr at glasgow.ac.uk>
> wrote:
>
>> Dear all,
>>
>> I want to implement an individual-based model and am unsure how to go
>> about this - here?s to hoping someone can point me in the right direction..
>>
>> I created a simple model (predator-prey like equations) which predicts the
>> number of scab mites from serological data (i.e. immune response) on a
>> **single** animal (see code below).
>> Immune response grows with mite count here.
>> Now I would like to extend the model from a single sheep towards an
>> individual-based model representing the flock of animals with two initial
>> states, ?clinical? and "sub-clinical? depending on the how large the immune
>> response is (i.e. small immune response = infested but no clinical signs).
>> So I guess I have to questions:
>>
>> (a) How can I go from a single animal model to an individual-based
>> population model?
>> (b) How can I integrate this into a two-stage model?
>>
>> Any thoughts are most welcome.
>>
>> Many thanks & best wishes,
>>
>> Sibylle
>>
>> ------------------------------------------------------------
>> -------------------------------------------------------------
>> The code:
>>
>> ## Immune response model
>>
>> require(simecol)
>> require(deSolve)
>>
>> # P = number of scab mites,
>> # E = ?amount? of protective immunity,
>> # W = mites in environment
>> # nu = intrinsic mite growth rate,
>> # mu*E = per-capita mite death rate,
>> # epsilon*P = per-capita growth of the immune response
>> # alpha = rate of decline of the immune response in the absence of
>> antigenic stimulation
>> # lambda = parasite environmental production
>> # gamma= = parasite environmental death
>> # beta = transmission rate
>>
>> ImmRespode <- {new("odeModel",
>> main = function(time, init, parms){
>> with(as.list(c(init, parms)),{
>>
>> dP <- P*(nu - mu*E)
>> dE <- -E*(alpha - epsilon*P)
>> dW <- (lambda*E) - (gamma*W) - (beta*W*P)
>>
>> list(c(dP, dE, dW))
>> })
>> },
>> times = c(from = 0, to = 365, by = 0.01),
>> init = c(P = 2, E = 2, W = 0),
>>
>> parms = c(nu = .11, mu = .01, epsilon = .00024, alpha
>> = .00024, lambda = .05, gamma = .05, beta=.05),
>> solver = "lsoda")
>> }
>> ImmRespode <- sim(ImmRespode)
>>
>> print(ImmRespode, all=TRUE)
>> ImmRespodedata <- out(ImmRespode) # ?simecol::out
>>
>> par(mfrow = c(1, 3))
>> plot(ImmRespodedata[,1], ImmRespodedata[,3], type="l", xlab = "Time
>> Period", ylab = "Immune response", col=2)
>> plot(ImmRespodedata[,1], ImmRespodedata[,2], type="l", xlab = "Time
>> Period", ylab = "Mite Density")
>> plot(ImmRespodedata[,1], ImmRespodedata[,4], type="l", xlab = "Time
>> Period", ylab = "Environment")
>>
>>
>>
>> --
>> Sibylle Mohr, Ph.D.
>> Institute of Biodiversity, Animal Health, and Comparative Medicine
>> College of Medical, Veterinary and Life Sciences
>> University of Glasgow
>> 464 Bearsden Rd. Glasgow G61 1QH
>> _______________________________________________
>> R-sig-dynamic-models mailing list
>> R-sig-dynamic-models at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models
>
>
>
>
> --
>
> *___________________________________________________________________________Jeremy
> M. Chacon, Ph.D.*
>
> *Post-Doctoral Associate, Harcombe Lab*
> *University of Minnesota*
> *Ecology, Evolution and Behavior*
>
> [[alternative HTML version deleted]]
>
>
>
> ------------------------------
>
> Message: 2
> Date: Thu, 6 Jul 2017 09:35:23 +0000
> From: Sibylle Mohr <Sibylle.Mohr at glasgow.ac.uk>
> To: "r-sig-dynamic-models at r-project.org"
> <r-sig-dynamic-models at r-project.org>
> Subject: Re: [R-sig-dyn-mod] Individual-based modelling
> Message-ID: <E7DF7B9E-18C0-4DA6-8BE1-7CF6A22EF3CA at glasgow.ac.uk>
> Content-Type: text/plain; charset="UTF-8"
>
> Hi John & Jeremy,
>
> Thank you both for your replies!
> John - in a way I wanted to have a ?mixed? model - though not strictly in the statistical sense but more as a dynamical mathematical model.
>
> Jeremy, your description is spot on - that?s exactly what I want to do.
> I will give the metapopulation approach a try.
>
> Many thanks & best wishes,
>
> Sibylle
>
>
> On 5 Jul 2017, at 11:00, r-sig-dynamic-models-request at r-project.org<mailto:r-sig-dynamic-models-request at r-project.org> wrote:
>
> Re: [R-sig-dyn-mod] Individual-based modelling
>
>
> [[alternative HTML version deleted]]
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> R-sig-dynamic-models mailing list
> R-sig-dynamic-models at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models
>
> ------------------------------
>
> End of R-sig-dynamic-models Digest, Vol 131, Issue 3
> ****************************************************
More information about the R-sig-dynamic-models
mailing list