-
Notifications
You must be signed in to change notification settings - Fork 4
Custom secondary models
Alberto Garre edited this page May 9, 2022
·
1 revision
This page shows how to define new functions as gamma factors. Please note that this is intended only for advanced users.
- Go to file gamma_models.R (you could do it in a different file, but it is easier this way).
- Define the function for the gamma function with any name (as long as it is not already within the package namespace).
- The first argument should be named
x
and represent the value of the environmental conditions as a numeric vector of any dimension. Additional arguments define the model parameters. - The function should return a numeric vector with the values of gamma with the same length as
x
. All these values should be between 0 and 1 (unless you REALLY know what you are doing).
- Go to the file metainfo_secondary.R
- Within the function secondary_model_data(), extend
model_data
with the meta-data of the new model. - This information should be a named list with 5 entries:
identifier
(the model key),name
(the full name of the model),pars
(a character vector of model parameters),model
(the model function defined before),ref
(the paper where the model was first published).
- Go to file gamma_models.R
- Go to function calculate_gammas().
- Modify the definition of variable
this_gamma
adding an additional option for theswitch
. - This new entry should be named with the same key defined in secondary_model_data().
- Its value should be a call to the function defined in the first step. The first argument calling this function should be
this_x
. Then, as many additional arguments as model parameters, passed asthis_sec$
+ "parameter name".
- You would need to build the package locally using the functions included in devtools. Please check the documentation of that package for details on how to do that.
- After taking the steps above, the functions for prediction and model fitting should work.
- If they do not, feel free to contact us.
- We will gladly include your model in the next CRAN release of biogrowth. We would appreciate if you could send a pull request, so we can review your changes and include the new model.