nlmixr2GradFun: Create a gradient function based on gill numerical...

View source: R/nlmixrGrad.R

nlmixr2Eval_R Documentation

Create a gradient function based on gill numerical differences

Description

Create a gradient function based on gill numerical differences

Usage

nlmixr2Eval_(theta, md5)

nlmixr2Unscaled_(theta, md5)

nlmixr2Grad_(theta, md5)

nlmixr2ParHist_(md5)

nlmixr2GradFun(
  what,
  envir = parent.frame(),
  which,
  thetaNames,
  gillRtol = sqrt(.Machine$double.eps),
  gillK = 10L,
  gillStep = 2,
  gillFtol = 0,
  useColor = crayon::has_color(),
  printNcol = floor((getOption("width") - 23)/12),
  print = 1
)

Arguments

theta

for the internal functions theta is the parameter values

md5

the md5 identifier for the internal gradient function information.

what

either a function or a non-empty character string naming the function to be called.

envir

an environment within which to evaluate the call. This will be most useful if what is a character string and the arguments are symbols or quoted expressions.

which

Which parameters to calculate the forward difference and optimal forward difference interval

thetaNames

Names for the theta parameters

gillRtol

The relative tolerance used for Gill 1983 determination of optimal step size.

gillK

The total number of possible steps to determine the optimal forward/central difference step size per parameter (by the Gill 1983 method). If 0, no optimal step size is determined. Otherwise this is the optimal step size determined.

gillStep

When looking for the optimal forward difference step size, this is This is the step size to increase the initial estimate by. So each iteration the new step size = (prior step size)*gillStep

gillFtol

The gillFtol is the gradient error tolerance that is acceptable before issuing a warning/error about the gradient estimates.

useColor

Boolean indicating if focei can use ASCII color codes

printNcol

Number of columns to printout before wrapping parameter estimates/gradient

print

Integer representing when the outer step is printed. When this is 0 or do not print the iterations. 1 is print every function evaluation (default), 5 is print every 5 evaluations.

Value

A list with 'eval', 'grad', 'hist' and 'unscaled' functions. This is an internal module used with dynmodel

Examples


func0 <- function(x){ sum(sin(x))  }

## This will printout every interation or when print=X
gf <- nlmixr2GradFun(func0)

## x
x <- (0:10)*2*pi/10;
gf$eval(x)
gf$grad(x)

## x2
x2 <- x+0.1
gf$eval(x2)
gf$grad(x2)

## Gives the parameter history as a data frame
gf$hist()


nlmixr2est documentation built on Oct. 30, 2024, 9:23 a.m.