[R-sig-dyn-mod] metapopulation model with random effect in parameters
Thomas Petzoldt
thom@@@petzoldt @ending from tu-dre@den@de
Thu Sep 27 10:26:50 CEST 2018
Hi,
this is a common task for the dynamic modeler, its solution depends on
the model and the data. Package 'simecol' contains two convenience
functions approxTime and approxTime1, but for small small models like
yours its easiest to write just three approxfun'ctions. You can put them
in a list, if you wish. approxfun is quite efficient, given that the
interpolation tables are not too big.
For larger models, one may consider to write an own interpolation
function. This works well and can be faster than approx, appproxfun or
approxTime, if data are given in equidistant resolution, because you can
then directly calculate the position of grid points without searching.
As an alternative, you can also supply a Fortran or C-model to deSolve.
Then deSolve provides a built-in interpolator.
Hope it helps,
Thomas
Am 27.09.2018 um 03:20 schrieb 胡艺:
> Thomas, thanks for your studying files and they are very useful. As for the
> above problem, there are three subpopulations in my model and I want each
> to have different birth rate. If I just use b1(time) in the model, there
> is only one birth rate for one subpopulation at each integration time,
> right? I'm wondering whether there is a way to let approxfun() to return
> three birth rates (a vector) at each integration time. Thanks.
>
> Yi
>
> On Wed, Sep 26, 2018 at 4:44 PM Thomas Petzoldt <
> thomas.petzoldt using tu-dresden.de> wrote:
>
>> Hi,
>>
>> Note that approxfun uses a special feature of R: It returns a function.
>>
>> If you create:
>>
>> b1<-approxfun(x=c(0,365),y=c(3,6),rule = 2)
>>
>> then just use
>>
>> b1(time)
>>
>> in your model.
>>
>>
>> Please read the ?approxfun help page again. For examples how to use it
>> with desolve, have a look at:
>>
>> http://limno-live.hydro.tu-dresden.de/user2017/
>>
>> and in particular:
>>
>>
>> http://limno-live.hydro.tu-dresden.de/user2017/2.1-forcing+events/desolve-forcing.html#(5)
>>
>> Thomas
>>
>>
>> --
>> http://tu-dresden.de/Members/thomas.petzoldt
More information about the R-sig-dynamic-models
mailing list