-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to include fitted models (GLM, GAM) into a FLSR-object #60
Comments
The model slot needs to be of class formula, yes, but that still allows you to use any function for prediction. If you can create a function that is able to predict recruitment based on any metric from the stock, predict(FLModel) will work on it. For example, model could have Would this work for your models? Note this will make it work in FLSR, but not for future projections using FLash or FLasher. The SRR models are hard coded in the C++ code, as we could not find any other way. Adding SRR models to FLasher is not that hard, but it is not trivial. If you fit a GLM or GAM to SR data, what kind of formulation do you use to predict future recruitment? |
Thank you very much! I managed to make it work based on your suggestions and included some example code:
create some Stock-Recruitment-data with 2 environmental covariates
create the FLSR-object
Fit a gam to the stock-recruitment relationship
Include the GAM in the FLSR-objectwrite the model as function
include as formula
|
Glad it worked. A small suggestion would be to take care of the recruitment lag in the dimnames of the returned FLQuant. For example for a rec.age of 1
|
How to include general SR-models (besides BH, ricker, hockey...) like already fitted GLMs or GAMs into the FLSR-framework? For now everything seems to be strongly focused on providing a formula, which can be fitted with "fmle" or "nls".
If you provide anything other to the @model-slot in the FLSR-object than a "formula" it throws the following error:
"assignment of an object of class “...” is not valid for @‘model’ in an object of class “FLSR”; is(value, "formula") is not TRUE"
My idea is to get around this by not using the internal fitting routines to get my SR-model, but to just provide a fitted model as basis for further predictions. One way I thought about is to overwrite the slots the FLSR-object gets its predictions from, but so far I have no clue where to look for in the code.
Thanks for your help.
The text was updated successfully, but these errors were encountered: