[R-sig-dyn-mod] replicates in stochastic model

Thomas Petzoldt thomas.petzoldt at tu-dresden.de
Mon Mar 18 14:08:24 CET 2013


Hi Pablo,

your question is not clear to me, so it is difficult to help you:

1) what is "times"? Is it the simulation time or is it the number of 
replicates?

2) the random variables are initialized once at the beginning of your 
script, but I assume that they should vary for each run?

3) Your popmod does not contain any assignment, so it returns just the 
original values.

Can you please be more specific, e.g. by giving a more conceptual (or 
mathematical) description of your problem ?

Thomas P.



Am 2013-03-18 7:15 AM, schrieb "Pablo García Díaz":
> Hi all,
>
> I am trying to model a simple demographic stochastic system in R, and its
> trajectorie during some years. For doing that I have written the following
> code:
>
> times=c(1:100)
> Nt=rpois(times, 10)
> phi=runif(times, 0.1,1)
> ri=rpois(times, 10)
> Ii=rpois(times,5)
>
> popmod<-function(times, Nt, phi, ri, Ii){
> for (i in times[-1]){
> Nt[times-1]*phi[times-1]+ ri[times-1]+Ii[times-1]
> 				}
> F=data.frame(Nt=Nt[times],year=times)
>
> }
>
>
> vf<-popmod(times, Nt, phi, ri, Ii)
>
> Now, what I want is to run some replictes (about 100) of the same model to
> obtain the estimate and standard deviation of the trajectorie. I have
> tried with the repeat loop, but until now all my attemps have failed.
>
> Can anyone plese provide me some guidance and/or help?
>
> Thanks in advance, best regards
>
> Pablo



More information about the R-sig-dynamic-models mailing list