Skip to content

Commit

Permalink
Allow profile to take character
Browse files Browse the repository at this point in the history
  • Loading branch information
seananderson committed Apr 22, 2024
1 parent 8958a46 commit fe5ead1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 4 additions & 0 deletions R/fit.R
Expand Up @@ -1364,6 +1364,10 @@ sdmTMB <- function(

prof <- c("b_j")
if (delta) prof <- c(prof, "b_j2")
if (is.character(control$profile)) {
prof <- control$profile
control$profile <- TRUE
}

out_structure <- structure(list(
data = data,
Expand Down
12 changes: 3 additions & 9 deletions R/methods.R
Expand Up @@ -115,15 +115,9 @@ confint.sdmTMB <- function(object, parm, level = 0.95, ...) {
logLik.sdmTMB <- function(object, ...) {
val <- -object$model$objective
nobs <- nobs.sdmTMB(object)
df <- length(object$model$par) # fixed effects only
if (isTRUE(object$reml)) {
s <- as.list(object$sd_report, "Estimate")
n_bs <- 0 # smoother FE
if (s$bs[1] != 0) { # starting value if mapped off
n_bs <- length(s$bs)
}
df <- df + length(s$b_j) + length(s$b_j2) + n_bs
}
lpb <- names(object$tmb_obj$env$last.par.best)
ran <- c("omega_s", "epsilon_st", "zeta_s", "b_rw_t", "epsilon_re", "RE", "b_smooth")
df <- sum(!lpb %in% ran)
structure(val,
nobs = nobs, nall = nobs, df = df,
class = "logLik"
Expand Down
2 changes: 2 additions & 0 deletions R/utils.R
Expand Up @@ -114,6 +114,8 @@ sdmTMBcontrol <- function(
parallel <- as.integer(parallel)
}

assert_that(is.logical(profile) || is.character(profile))

out <- named_list(
eval.max,
iter.max,
Expand Down

0 comments on commit fe5ead1

Please sign in to comment.