Skip to content

Commit

Permalink
Update do.fit=FALSE to return list with report in it
Browse files Browse the repository at this point in the history
  • Loading branch information
Cole-Monnahan-NOAA committed Sep 25, 2024
1 parent 35c9838 commit c153cb1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
14 changes: 8 additions & 6 deletions R/fimsfit.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ print.fimsfit <- function(fit, ...){
#' Hessian to do after optimization.
#' @param control A list of optimizer settings passed to code{nlminb}
#' @param getsd Calculate and return sdreport?
#' @param do.fit Optimize or return obj? Used for testing.
#' @param do.fit Optimize (TRUE, default) or (FALSE) build and return
#' a list containing the obj and report slot.
#' @param save.sdrep Whether to return the sdreport object in the
#' fitted model. This is rarely used and large so turned off by
#' default. When returned it is named `sdrep`.
Expand All @@ -93,10 +94,11 @@ print.fimsfit <- function(fit, ...){
#' and a value of NULL indicates not to save it. If specified,
#' it must end in .RDS. The file is written to folder given by
#' \code{input$path}.
#' @return A list object of class 'fimsfit' which contains a
#' "version" model name, rep, parList (MLE in list format), opt
#' as returned by \code{nlminb}, std (formatted data frame) and sdrep if
#' \code{getsd=TRUE}, and the obj.
#' @return If \code{do.fit} is TRUE then a list object of class 'fimsfit'
#' which contains a "version" model name, rep, parList (MLE in list format),
#' opt as returned by \code{nlminb}, std (formatted data frame) and sdrep if
#' \code{getsd=TRUE}, and the obj. If \code{do.fit} is FALSE then it returns
#' a list containing the TMB obj and rep slot for the report.
#' @details This function is a beta version still and subject to change
#' without warning.
#' @export
Expand All @@ -115,7 +117,7 @@ if (loopnum < 0) {
obj <- MakeADFun(data=list(), parameters=input$parameters,
map=input$map, random=input$random,
DLL='FIMS', silent=TRUE)
if(!do.fit) return(obj)
if(!do.fit) return(list(obj=obj, rep=obj$report(obj$env$last.par.best)))
# to do: max this update elements that are not supplied by default
if(is.null(control))
control <- list(eval.max=10000, iter.max=10000, trace=0)
Expand Down
12 changes: 7 additions & 5 deletions man/fit_fims.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c153cb1

Please sign in to comment.