If the way mizer calculates a fundamental rate entering the model is
not flexible enough for you (for example if you need to introduce time
dependence) then you can write your own functions for calculating that
rate and use `setRateFunction()`

to register it with mizer.

setRateFunction(params, rate, fun) getRateFunction(params, rate) other_params(params) other_params(params) <- value

params | A MizerParams object |
---|---|

rate | Name of the rate for which a new function is to be set. |

fun | Name of the function to use to calculate the rate. |

value | Values for other parameters |

For `setRateFunction()`

: An updated MizerParams object

For `getRateFunction()`

: The name of the registered rate function for
the requested `rate`

, or the list of all rate functions if called without
`rate`

argument.

For `other_params()`

: A named list with all the parameters for which
you have set values.

At each time step during a simulation with the `project()`

function, mizer
needs to calculate the instantaneous values of the various rates. By
default it calls the `mizerRates()`

function which creates a list with the
following components:

`encounter`

from`mizerEncounter()`

`feeding_level`

from`mizerFeedingLevel()`

`pred_rate`

from`mizerPredRate()`

`pred_mort`

from`mizerPredMort()`

`f_mort`

from`mizerFMort()`

`mort`

from`mizerMort()`

`resource_mort`

from`mizerResourceMort()`

`e`

from`mizerEReproAndGrowth()`

`e_repro`

from`mizerERepro()`

`e_growth`

from`mizerEGrowth()`

`rdi`

from`mizerRDI()`

`rdd`

from`BevertonHoltRDD()`

For each of these you can substitute your own function. So for example if
you have written your own function for calculating the total mortality
rate and have called it `myMort`

and have a mizer model stored in a
MizerParams object called `params`

that you want to run with your new
mortality rate, then you would call

params <- setRateFunction(params, "Mort", "myMort")

In general if you want to replace a function `mizerSomeRateFunc()`

with
a function `myVersionOfThis()`

you would call

params <- setRateFunction(params, "SomeRateFunc", "myVersionOfThis")

In some extreme cases you may need to swap out the entire `mizerRates()`

function for your own function called `myRates()`

. That you can do with

params <- setRateFunction(params, "Rates", "myRates")

Your new rate functions may need their own model parameters. These you
can store in `other_params(params)`

. For example

other_params(params)$my_param <- 42

Note that your own rate functions need to be defined in the global environment or in a package. If they are defined within a function then mizer will not find them.