Skip to content

Commit

Permalink
try removing ThorsonUtilities
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Thorson committed Jan 16, 2025
1 parent 38bc825 commit b8070ed
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/R-CMD-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
run: |
remotes::install_deps(dependencies=TRUE)
remotes::install_cran("rcmdcheck")
install.packages("INLA",repos=c(getOption("repos"),INLA="https://inla.r-inla-download.org/R/stable"), dep=TRUE)
shell: Rscript {0}

- name: Check Ubuntu
Expand Down
4 changes: 1 addition & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Imports:
abind,
effects,
stats,
ThorsonUtilities,
utils,
fmesher,
remotes,
Expand All @@ -42,11 +41,10 @@ Suggests:
lme4,
Remotes:
james-thorson-NOAA/FishStatsUtils,
james-thorson/utilities
License: file LICENSE
LazyData: true
Encoding: UTF-8
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
ByteCompile: true
URL: http://github.com/James-Thorson-NOAA/VAST
BugReports: http://github.com/James-Thorson-NOAA/VAST/issues
Expand Down
35 changes: 35 additions & 0 deletions R/list_parameters.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@


#' List fixed and random effects
#'
#' \code{list_parameters} lists all fixed and random effects
#'
#' @param Obj Compiled TMB object
#' @return Return Tagged-list of fixed and random effects (returned invisibly)

#' @export
list_parameters = function( Obj, verbose=TRUE ){
Return = list()
Table = data.frame()
if( length(Obj$env$random)>0 ){
Return[["Fixed_effects"]] = names(Obj$env$last.par[-Obj$env$random])
Return[["Random_effects"]] = names(Obj$env$last.par[Obj$env$random])
Table = data.frame( "Coefficient_name"=names(table(Return[["Fixed_effects"]])),
"Number_of_coefficients"=as.numeric(table(Return[["Fixed_effects"]])),
"Type"="Fixed")
Table = rbind( Table,
data.frame("Coefficient_name"=names(table(Return[["Random_effects"]])),
"Number_of_coefficients"=as.numeric(table(Return[["Random_effects"]])),
"Type"="Random"))
}else{
Return[["Fixed_effects"]] = names(Obj$env$last.par)
Table = data.frame( "Coefficient_name"=names(table(Return[["Fixed_effects"]])),
"Number_of_coefficients"=as.numeric(table(Return[["Fixed_effects"]])),
"Type"="Fixed")
}
if( verbose==TRUE ){
message("List of estimated fixed and random effects:")
print(Table)
}
return( invisible(Table) )
}
2 changes: 1 addition & 1 deletion R/make_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ function( TmbData,
Obj$env$inner.control$grad.tol <- c(1e-8,1e-12,1e-15)[ConvergeTol] # # Default : 1e-8 # Maximum gradient limit inner optimization

# Print number of parameters
ThorsonUtilities::list_parameters( Obj )
list_parameters( Obj )

# Return stuff
Return = list("Obj"=Obj, "Upper"=Bounds[,'Upper'], "Lower"=Bounds[,'Lower'], "Parameters"=Parameters, "Map"=Map, "Random"=Random)
Expand Down
5 changes: 3 additions & 2 deletions R/project_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
#'
#' The function specifically simulates new values for random effects occurring
#' during forecasted years. This includes some combination of intercepts
#' {beta1/beta2} and spatio-temporal terms {epsilon1/epsilon2} depending on which
#' \code{beta1} or \code{beta2} and spatio-temporal terms
#' \code{epsilon1} or \code{epsilon2} depending on which
#' are treated as random during estimation. It does *not* generate new values of
#' covariates or random-effects that are not indexed by time {omega1/omega2}
#' covariates or random-effects that are not indexed by time \code{omega1} or \code{omega2}
#'
#' Note that the model may behave poorly when \code{historical_uncertainty="both"}
#' and the estimation model includes an AR1 process for any component.
Expand Down
17 changes: 17 additions & 0 deletions man/list_parameters.Rd

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

Binary file added tests/testthat/testthat-problems.rds
Binary file not shown.

0 comments on commit b8070ed

Please sign in to comment.