A wrapper for running a TMB model to estimate ageing error for a given data set and specification file.
Examples
if (FALSE) { # \dontrun{
data_test <- data.frame(
reader1 = c(7, 10, 7, 6, 6, 10, 7, 9, 8, 10, 10, 5, 6, 7, 9, 7, 7, 5, 8, 5),
reader2 = c(8, 10, 7, 6, 6, 10, 7, 9, 8, 10, 10, 5, 6, 7, 9, 7, 7, NA, NA, NA),
reader3 = c(7, 10, 7, 6, 6, 8, 7, 9, 8, 10, 10, 5, 6, 7, NA, NA, NA, 5, 8, 5)
)
write_files(dat = data_test, dir = tempdir())
out <- run(dir = tempdir())
# see estimated parameters
out$model$par
# see model selection results
out$output$ModelSelection
# see ageing error matrices
out$output$ErrorAndBiasArray
# add to an SS3 model (assumes the model already has a single
# ageing error matrix and a maxage <= maxage in the ageing error model)
ss3_inputs <- r4ss::SS_read()
maxage <- ss3_inputs$dat$Nages
ss3_inputs$dat$ageerror <-
out$output$ErrorAndBiasArray[c("Expected_age", "SD"), 1 + 0:maxage, "Reader 1"] |>
as.data.frame()
r4ss::SS_write(inputlist = ss3_inputs)
} # }