Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 752-respect-interp
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Aug 7, 2024
2 parents 54d4157 + 57c9980 commit 95ad4ec
Show file tree
Hide file tree
Showing 12 changed files with 248 additions and 86 deletions.
22 changes: 21 additions & 1 deletion R/rxsolve.R
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,19 @@
#' end/beginning of the individual record, switch direction. If all
#' are really missing, then return missing.
#'
#' @param keepInterpolation specifies the interpolation method for
#' variables in the `keep` column. When `nlmixr2` creates `mtime`,
#' `addl` doses etc, these items were not originally in the dataset.
#' The interpolation methods you can choose are:
#'
#' * `"locf"` -- last observation carried forward (default)
#'
#' * `"nocb"` -- next observation carried backward.
#'
#' * `"na"` -- no interpolation, simply put `NA` for the
#' interpolated `keep` covariates.
#'
#'
#' @param addCov A boolean indicating if covariates should be added
#' to the output matrix or data frame. By default this is
#' disabled.
Expand Down Expand Up @@ -686,6 +699,7 @@ rxSolve <- function(object, params = NULL, events = NULL, inits = NULL,
cores,
covsInterpolation = c("locf", "linear", "nocb", "midpoint"),
naInterpolation = c("locf", "nocb"),
keepInterpolation=c("locf", "nocb", "na"),
addCov = TRUE, sigma = NULL, sigmaDf = NULL,
sigmaLower = -Inf, sigmaUpper = Inf,
nCoresRV = 1L, sigmaIsChol = FALSE,
Expand Down Expand Up @@ -819,11 +833,16 @@ rxSolve <- function(object, params = NULL, events = NULL, inits = NULL,
} else {
covsInterpolation <- c("linear"=0L, "locf"=1L, "nocb"=2L, "midpoint"=3L)[match.arg(covsInterpolation)]
}
if (checkmate::testIntegerish(naInterpolation, len=1, lower=0, upper=2, any.missing=FALSE)) {
if (checkmate::testIntegerish(naInterpolation, len=1, lower=0, upper=1, any.missing=FALSE)) {
naInterpolation <- as.integer(naInterpolation)
} else {
naInterpolation <- c("locf"=1L, "nocb"=0L)[match.arg(naInterpolation)]
}
if (checkmate::testIntegerish(keepInterpolation, len=1, lower=0, upper=2, any.missing=FALSE)) {
keepInterpolation <- as.integer(keepInterpolation)
} else {
keepInterpolation <- c("locf"=1L, "nocb"=0L, "na"=2L)[match.arg(keepInterpolation)]
}
if (missing(naTimeHandle) && !is.null(getOption("rxode2.naTimeHandle", NULL))) {
naTimeHandle <- getOption("rxode2.naTimeHandle")
}
Expand Down Expand Up @@ -1158,6 +1177,7 @@ rxSolve <- function(object, params = NULL, events = NULL, inits = NULL,
ssAtDoseTime=ssAtDoseTime,
ss2cancelAllPending=ss2cancelAllPending,
naInterpolation=naInterpolation,
keepInterpolation=keepInterpolation,
.zeros=unique(.zeros)
)
class(.ret) <- "rxControl"
Expand Down
3 changes: 2 additions & 1 deletion inst/include/rxode2_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,6 @@
#define Rxc_ssAtDoseTime 92
#define Rxc_ss2cancelAllPending 93
#define Rxc_naInterpolation 94
#define Rxc__zeros 95
#define Rxc_keepInterpolation 95
#define Rxc__zeros 96
#endif // __rxode2_control_H__
1 change: 1 addition & 0 deletions inst/include/rxode2parseStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ typedef struct {
// approx fun options
int is_locf;
int instant_backward;
int keep_interp;
int cores;
int doesRandom;
int extraCmt;
Expand Down
3 changes: 2 additions & 1 deletion inst/include/rxode2parse_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
#define Rxc_ssAtDoseTime 92
#define Rxc_ss2cancelAllPending 93
#define Rxc_naInterpolation 94
#define Rxc__zeros 95
#define Rxc_keepInterpolation 95
#define Rxc__zeros 96
#define RxMv_params 0
#define RxMv_lhs 1
#define RxMv_state 2
Expand Down
12 changes: 12 additions & 0 deletions man/rxSolve.Rd

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

Loading

0 comments on commit 95ad4ec

Please sign in to comment.