Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
msuchard committed Nov 1, 2024
2 parents a83ba43 + 5149fe3 commit a4855f1
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ Suggests:
microbenchmark,
cmprsk
NeedsCompilation: yes
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
Encoding: UTF-8
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
develop
==============

1. make `maxResets` a function parameter
2. provide optional (`optimalWarmStart = FALSE`) more parallelization when profiling likelihood

Cyclops v3.4.1
==============

Expand Down
22 changes: 17 additions & 5 deletions R/ModelFit.R
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,10 @@ confint.cyclopsFit <- function(object, parm, level = 0.95, #control,
#' @param bounds Pair of values to bound adaptive profiling
#' @param tolerance Absolute tolerance allowed for adaptive profiling
#' @param initialGridSize Initial grid size for adaptive profiling
#' @param maxResets Maximum allowed number of recomputing the likelihood when coefficient drift is
#' detected.
#' @param includePenalty Logical: Include regularized covariate penalty in profile
#' @param optimalWarmStart Logical: Use optimal warm-starting when parallelizing evaluations
#'
#' @return
#' A data frame containing the profile log likelihood. Returns NULL when the adaptive profiling fails
Expand All @@ -915,8 +918,10 @@ getCyclopsProfileLogLikelihood <- function(object,
bounds = NULL,
tolerance = 1E-3,
initialGridSize = 10,
includePenalty = TRUE) {
maxResets <- 10
maxResets = 10,
includePenalty = TRUE,
optimalWarmStart = TRUE) {

if (!xor(is.null(x), is.null(bounds))) {
stop("Must provide either `x` or `bounds`, but not both.")
}
Expand All @@ -935,7 +940,8 @@ getCyclopsProfileLogLikelihood <- function(object,
priorMaxMaxError <- Inf
resetsPerformed <- 0
while (length(grid) != 0) {
ll <- fixedGridProfileLogLikelihood(object, parm, grid, includePenalty)
ll <- fixedGridProfileLogLikelihood(object, parm, grid, includePenalty,
optimalWarmStart)
profile <- bind_rows(profile, ll) %>% arrange(.data$point)
invalid <- is.nan(profile$value) | is.infinite(profile$value)
if (any(invalid)) {
Expand Down Expand Up @@ -999,19 +1005,25 @@ getCyclopsProfileLogLikelihood <- function(object,
grid <- (profile$point[exceed] + profile$point[exceed + 1]) / 2
}
} else { # Use x
profile <- fixedGridProfileLogLikelihood(object, parm, x, includePenalty)
profile <- fixedGridProfileLogLikelihood(object, parm, x, includePenalty,
optimalWarmStart)
}

return(profile)
}

fixedGridProfileLogLikelihood <- function(object, parm, x, includePenalty) {
fixedGridProfileLogLikelihood <- function(object, parm, x, includePenalty,
optimalWarmStart = TRUE) {

.checkInterface(object$cyclopsData, testOnly = TRUE)
parm <- .checkCovariates(object$cyclopsData, parm)
threads <- object$threads

if (getNumberOfCovariates(object$cyclopsData) == 1 || length(x) == 1) {
grid <- .cyclopsGetProfileLikelihood(object$cyclopsData$cyclopsInterfacePtr, parm, x,
threads, includePenalty)
} else if (!optimalWarmStart && length(x) / 2 >= threads) {

grid <- .cyclopsGetProfileLikelihood(object$cyclopsData$cyclopsInterfacePtr, parm, x,
threads, includePenalty)
} else {
Expand Down
30 changes: 30 additions & 0 deletions man/cyclops.Rd

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

9 changes: 8 additions & 1 deletion man/getCyclopsProfileLogLikelihood.Rd

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

0 comments on commit a4855f1

Please sign in to comment.