merrillrudd / LIME

Length-based integrated mixed effects model
MIT License
12 stars 15 forks source link

More of a Question - how to run LIME for multiple species at once? #14

Closed danagrieco closed 1 year ago

danagrieco commented 1 year ago

Hello! I am trying to try and figure out how to run LIME for multiple species consecutively, and so I have created a table in my environment (LIME_data_all) that has names for many species in a column (sci_name) and then life history traits/LIME inputs in subsequent columns, with appropriate names for the create_lh_list function (e.g. vbk, linf, lwa, etc.). However, I am wondering how to change the script (pasted below) to instead bring-in this table with multiple species.

Any feedback would be helpful! Thank you so much!



Now let's populate the `create_lh_list` function with example values.
```{r, tidy=TRUE}
lh <- create_lh_list(vbk=0.21, 
           linf=65, 
           t0=-0.01,
           lwa=0.0245, 
           lwb=2.79, 
           S50=c(20), 
           S95=c(26), 
           selex_input="length",
           selex_type=c("logistic"),
           M50=34,
           maturity_input="length",
           M=0.27, 
           binwidth=1,
           CVlen=0.1,
           SigmaR=0.737,
           SigmaF=0.2,
           SigmaC=0.1,
           SigmaI=0.1,
           R0=1,
           Frate=0.1,
           Fequil=0.25,
           qcoef=1e-5,
           start_ages=0,
           rho=0.43,
           theta=10,
           nseasons=1,
           nfleets=1)
```
merrillrudd commented 1 year ago

Hi Dana -- that function create_lh_list just brings the required life history information together in the correct format for model input. LIME is inherently single-species, so of course you could run LIME multiple times for each species. You'll just have to write your own function that loops through each species. For each species, it would pull the correct row from your data frame, use the LIME package code to run the model, save the results, and then move on to the next species. You could do that sequentially or in parallel, but either way the LIME package is only built for one species at a time.

If you're interested in making changes/adjustments to LIME code itself you can always make a branch on this public repository to play around. Unfortunately I do not keep up regular maintenance on LIME but I am glad the code and ideas from it can continue to be used for many applications worldwide.