NB Once you have installed LIME, you don't need to run the install.packages code chunk again.

At https://github.com/merrillrudd/LIME/wiki/2---Introduction-and-installation, it is stated that "the LIME package can be used in two ways: 1) simulating the expected age-structured population dynamics, length composition, catch data, and an abundance index using LIME and 2) fitting to empirical length data (at a minimum), plus any available catch and/or abundance index data, to provide an estimate of the spawning potential ratio (NB We are assuming that you have saved our test data in the same directory as the R markdown code and that you have opened a new R session. Otherwise you can change our code to point to the directory where the data file is and call it your working directory using the setwd command.

Create length data: ```{r Create_LengthData, echo=TRUE} temp <- read.csv("LengthData.csv",header=T) ### assign the first column to be years, and columns 5:21 as the length-frequency data years <- temp[,1] LenFreq <- as.matrix(temp[,5:21]) rownames(LenFreq) <- years ## adjust with the true midpoints mids <- seq(10, by = 5, length.out = ncol(LenFreq)) colnames(LenFreq) <- mids ``` #### Catch index (NB LIME can also use abundance data, if available - see vignettes) Our test data also includes a time series of catch, which LIME can use. These data should be in matrix form, with fleets as the the rows and years as the columns. With one fleet, the time series should still be in matrix form rather than a vector (the model will look for the first row, for the one and only fleet). Note that the length-frequency example data are from 1971-2001. The number of years of catch data should match the total number of years modelled, so we will need only the catch data from 1971-2001. (That is, for our example data, we only need rows 12-42). We have observed catch-by-age data; we will read this in and sum over the ages. Note that the catch data columns must be labelled with the years. Years must match up across the catch and length-frequency data sets. If there are missing years in the length data, all length bins can be filled with zeros (they are not registered as true zeros, but a row summing to 0 is a flag not to fit to that row). If there are missing years in the catch data, a negative value can be inserted for that year. We again assume you have saved the data to the same directory as your working directory. Create catch data: ```{r Create_CatchData, echo=TRUE} temp <- read.csv("TotalCatchAge.csv",header=T) Catch <- as.matrix(t(apply(temp[12:42,],1,sum))) ##MR edit colnames(Catch) <- years ``` #### Data input Observations LIME requires inputing observed data in a list form, including: . years: inclusive years to be modeled . LF: length-frequency data in matrix, array, or list form . neff_ft: effective sample size to use in case of the multinomial distribution (otherwise use Dirichlet multinomial to estimate effective sample size, or assume nominal sample size = effective sample size if not included) . I_ft: Index of abundance by fleet and time (if applicable) . C_ft: Catch by fleet and time (if applicable) in numbers or biomass (to be specified later) We don't have sample sizes for our test data set, but this is okay - under default run_LIME arguments, the effective sample size is estimated using the Dirichlet-multinomial likelihood so you don't need to specify them. The input sample sizes are only used with the multinomial likelihood. Formatting the model input data type: ```{r DataInput, echo=TRUE} data_all <- list(years = years, LF = LenFreq, C_ft = Catch) ``` Life history and starting values LIME includes a function