Skip to content

Commit

Permalink
FOCE
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Aug 25, 2018
1 parent f1669c2 commit 5636bf9
Show file tree
Hide file tree
Showing 22 changed files with 152 additions and 626 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Expand Up @@ -45,6 +45,6 @@ LinkingTo: dparser(>= 0.1.8), Rcpp (>= 0.12.3),
URL: https://github.com/nlmixrdevelopment/nlmixr
LazyData: true
VignetteBuilder: knitr
RoxygenNote: 6.0.1
RoxygenNote: 6.1.0
Packaged: 2018-04-30 01:43:13 UTC; annie
Maintainer: Wenping Wang <wwang8198@gmail.com>
26 changes: 19 additions & 7 deletions R/foceiFit.R
Expand Up @@ -168,6 +168,9 @@ is.latex <- function() {
##' @param noAbort Boolean to indicate if you should abort the FOCEi
##' evaluation if it runs into troubles. (default TRUE)
##'
##' @param interaction Boolean indicate FOCEi should be used (TRUE)
##' instead of FOCE (FALSE)
##'
##' @inheritParams RxODE::rxSolve
##'
##' @details
Expand Down Expand Up @@ -228,6 +231,7 @@ foceiControl <- function(sigdig=4,
boundTol=NULL,
calcTables=TRUE,
noAbort=TRUE,
interaction=TRUE,
..., stiff){
if (is.null(boundTol)){
boundTol <- 5 * 10 ^ (-sigdig + 1)
Expand Down Expand Up @@ -336,7 +340,8 @@ foceiControl <- function(sigdig=4,
boundTol=as.double(boundTol),
calcTables=calcTables,
printNcol=as.integer(printNcol),
noAbort=as.integer(noAbort));
noAbort=as.integer(noAbort),
interaction=as.integer(interaction));
class(.ret) <- "foceiControl"
return(.ret);
}
Expand Down Expand Up @@ -448,15 +453,20 @@ constructLinCmt <- function(fun){
##' w7$EVID <- 0
##' w7$AMT <- 0
##'
##' ## Wang2007 prop error 39.458 for NONMEM, nlmixr matches.
##' fitP <- foceiFit(w7, inits, mypar2,mod,pred,errProp,
##' ## Wang2007 prop error 39.458 for NONMEM FOCEi, nlmixr matches.
##' fitPi <- foceiFit(w7, inits, mypar2,mod,pred,errProp,
##' control=foceiControl(maxOuterIterations=0,covMethod=""))
##'
##' ## Wang2007 prop error 39.207 for NONMEM FOCE; nlmixr matches.
##' fitP <- foceiFit(w7, inits, mypar2,mod,pred,errProp,
##' control=foceiControl(maxOuterIterations=0,covMethod="",
##' interaction=FALSE))
##'
##' ## Note if you have the etas you can evaluate the likelihood
##' ## of an arbitrary model. It doesn't have to be solved by
##' ## FOCEi
##'
##' etaMat <- matrix(fitP$eta[,-1])
##' etaMat <- matrix(fitPi$eta[,-1])
##'
##' fitP2 <- foceiFit(w7, inits, mypar2,mod,pred,errProp, etaMat=etaMat,
##' control=foceiControl(maxOuterIterations=0,maxInnerIterations=0,
Expand Down Expand Up @@ -786,7 +796,9 @@ foceiFit.data.frame0 <- function(data,
if (!exists("noLik", envir=.ret)){
.ret$model <- RxODE::rxSymPySetupPred(model, pred, PKpars, err, grad=(control$derivMethod == 2L),
pred.minus.dv=TRUE, sum.prod=control$sumProd,
theta.derivs=FALSE, optExpression=control$optExpression, run.internal=TRUE);
theta.derivs=FALSE, optExpression=control$optExpression,
interaction=(control$interaction == 1L),
run.internal=TRUE);

.covNames <- .parNames <- RxODE::rxParams(.ret$model$pred.only);
.covNames <- .covNames[regexpr(rex::rex(start, or("THETA", "ETA"), "[", numbers, "]", end), .covNames) == -1];
Expand Down Expand Up @@ -1264,8 +1276,8 @@ print.nlmixrFitCore <- function(x, ...){
}
.posthoc <- (x$control$maxOuterIterations == 0L & x$control$maxInnerIterations > 0L)
.posthoc <- ifelse(.posthoc, paste0(crayon::bold(" posthoc"), " estimation"), " fit");
message(cli::rule(paste0(crayon::bold$blue("nlmix"), crayon::bold$red("r"), " ", crayon::bold$yellow(x$method),.posthoc,
x$extra)))
message(cli::rule(paste0(crayon::bold$blue("nlmix"), crayon::bold$red("r"), " ", crayon::bold$yellow(x$method),
x$extra, .posthoc)))
print(x$objDf)
message(paste0("\n", cli::rule(paste0(crayon::bold("Time"), " (sec; ", crayon::yellow(.bound), crayon::bold$blue("$time"), "):"))));
print(x$time)
Expand Down
20 changes: 4 additions & 16 deletions R/simulate.R
Expand Up @@ -90,7 +90,8 @@
##' simulated from the uncertainty in the Omega/Sigma matrices based
##' on the number of subjects and observations the model was based on.
##'
##' @inheritParams RxODE::rxSolve
##' @param object nlmixr object
##' @param ... Other arguments sent to \code{rxSolve}
##'
##' @export
nlmixrSim <- function(object, ...){
Expand Down Expand Up @@ -208,26 +209,13 @@ plot.nlmixrSim <- function(x, y, ...){
##' @param ipred Flag to calculate individual predictions. When
##' \code{ipred} is \code{TRUE}, calculate individual predictions.
##' When \code{ipred} is \code{FALSE}, set calculate typical population predations.
##' When \code{ipred} is \code{NA}, calculateboth individual and
##' When \code{ipred} is \code{NA}, calculate both individual and
##' population predictions.
##'
##' @inheritParams RxODE::rxSolve
##'
##' @export
nlmixrPred <- function(object, params=NULL, events=NULL, inits = NULL, scale = NULL,
covs = NULL, method = c("liblsoda", "lsoda", "dop853"),
transitAbs = NULL, atol = 1.0e-6, rtol = 1.0e-4,
maxsteps = 5000L, hmin = 0L, hmax = NULL, hini = 0L, maxordn = 12L, maxords = 5L, ...,
cores, covsInterpolation = c("linear", "locf", "nocb", "midpoint"),
addCov = FALSE, matrix = FALSE, sigma = NULL, sigmaDf = NULL,
nCoresRV = 1L, sigmaIsChol = FALSE, nDisplayProgress=10000L,
amountUnits = NA_character_, timeUnits = "hours", stiff,
theta = NULL, eta = NULL, addDosing=FALSE, updateObject=FALSE,doSolve=TRUE,
omega = NULL, omegaDf = NULL, omegaIsChol = FALSE,
nSub = 1L, thetaMat = NULL, thetaDf = NULL, thetaIsChol = FALSE,
nStud = 1L, dfSub=0.0, dfObs=0.0, returnType=c("data.frame", "rxSolve", "matrix"),
seed=NULL, nsim=NULL,
ipred=FALSE){
nlmixrPred <- function(object, ..., ipred=FALSE){
lst <- as.list(match.call()[-1]);
if (RxODE::rxIs(lst$params, "rx.event")){
if (!is.null(lst$events)){
Expand Down
8 changes: 4 additions & 4 deletions man/configsaem.Rd

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

20 changes: 20 additions & 0 deletions man/dot-collectWarnings.Rd

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

4 changes: 2 additions & 2 deletions man/dynmodel.Rd

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

17 changes: 10 additions & 7 deletions man/foceiControl.Rd

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

11 changes: 8 additions & 3 deletions man/foceiFit.Rd

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

4 changes: 2 additions & 2 deletions man/gen_saem_user_fn.Rd

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

3 changes: 2 additions & 1 deletion man/lincmt.Rd

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

12 changes: 6 additions & 6 deletions man/nlme_lin_cmpt.Rd

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

18 changes: 9 additions & 9 deletions man/nlme_ode.Rd

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

7 changes: 4 additions & 3 deletions man/nlmixr.Rd

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

9 changes: 5 additions & 4 deletions man/nlmixrAugPred.Rd

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

3 changes: 2 additions & 1 deletion man/nlmixrBounds.focei.upper.lower.Rd

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

0 comments on commit 5636bf9

Please sign in to comment.