[R-sig-eco] population simulations in R

Duncan Golicher dgolicher at gmail.com
Sun Jan 13 14:25:27 CET 2013


Hello Peter,

It should be easy to adapt this to your needs.

http://duncanjg.wordpress.com/2008/03/12/disturbance-and-the-lotka-volterra-competition-model/

All the best,

Duncan

On Sun, Jan 13, 2013 at 11:40 AM, Peter Houk <peterhouk at gmail.com> wrote:
> Greetings all -
>
> I'm in the process of fitting some population models and had a question
> regarding the simulation process in R.  Below I've pasted a simple code for
> logistic growth with some stochasticity in the growth rate parameter ("r" -
> see the runif part of the code).  If you run continue to repeat this code
> you get a similar, but distinct and unique population model (i.e., graph of
> population versus time) each time.  What I'm figure out is how to automate
> the process to do this say...10 times...and plot all ten simulations on one
> graph.  I'm trying to use a matrix approach, and fill each element.
> However, I'm having difficulties figuring things out.
>
> I appreciate any assistance offered,
>
> Peter
>
>
> Code:
>
>
> test.logistic<-function(alpha=0.01, r0=1.2, f=0.2, N0=80, t=100) {
> r<-c(r0, numeric(t))
> for (i in 1:t) r[i+1]<- {
> runif(1,0.8,1.1)
> }
> N<-c(N0, numeric(t))
> for (k in 1:t) N[k+1]<- {
> (N[k]+r[i]*N[k]*(1-(N[k]*alpha))-f*N[k])
> }
> return(N)
> }
> Nts<-bevholt()
> t<-100
> plot(0:t, Nts, type="l")
>
>
>
>
>
> --
> Peter Houk, PhD
> Chief Biologist
> Pacific Marine Resources Institute
> www.pacmares.com
> www.micronesianfishing.com
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology



-- 
Dr Duncan Golicher
Investigador Titular,
El Colegio de la Frontera Sur, Chiapas,Mexico
Mexico tel +52 1 967 137 94 20
Skype name duncangolicher

Publications: http://www.mendeley.com/profiles/duncan-golicher

Senior lecturer, Bournemouth University, UK
Centre for Conservation Ecology & Environmental Change
School of Applied Sciences
Christchurch House rm C218a
Bournemouth University
Fern Barrow
Poole (Dorset) BH12 5BB UK
Tel. +44 (0)1202 961682

For list of publications see Researcher ID:
http://www.researcherid.com/rid/B-4240-2009

dgolicher at bournemouth.ac.uk
dgoliche at ecosur.mx

Researcher ID:
http://www.researcherid.com/rid/B-4240-2009



More information about the R-sig-ecology mailing list