nlmixrGill83 | R Documentation |
Get the optimal forward difference interval by Gill83 method
nlmixrGill83( what, args, envir = parent.frame(), which, gillRtol = sqrt(.Machine$double.eps), gillK = 10L, gillStep = 2, gillFtol = 0 )
what |
either a function or a non-empty character string naming the function to be called. |
args |
a list of arguments to the function call. The
|
envir |
an environment within which to evaluate the call. This
will be most useful if |
which |
Which parameters to calculate the forward difference and optimal forward difference interval |
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. |
A data frame with the following columns:
infoGradient evaluation/forward difference information
hfForward difference final estimate
dfDerivative estimate
df22nd Derivative Estimate
errError of the final estimate derivative
aEpsAbsolute difference for forward numerical differences
rEpsRelative Difference for backward numerical differences
aEpsCAbsolute difference for central numerical differences
rEpsCRelative difference for central numerical differences
The info
returns one of the following:
Not AssessedGradient wasn't assessed
GoodSuccess in Estimating optimal forward difference interval
High Grad ErrorLarge error; Derivative estimate error fTol
or more of the derivative
Constant GradFunction constant or nearly constant for this parameter
Odd/Linear GradFunction odd or nearly linear, df = K, df2 ~ 0
Grad changes quicklydf2 increases rapidly as h decreases
Matthew Fidler
## These are taken from the numDeriv::grad examples to show how ## simple gradients are assessed with nlmixrGill83 nlmixrGill83(sin, pi) nlmixrGill83(sin, (0:10)*2*pi/10) func0 <- function(x){ sum(sin(x)) } nlmixrGill83(func0 , (0:10)*2*pi/10) func1 <- function(x){ sin(10*x) - exp(-x) } curve(func1,from=0,to=5) x <- 2.04 numd1 <- nlmixrGill83(func1, x) exact <- 10*cos(10*x) + exp(-x) c(numd1$df, exact, (numd1$df - exact)/exact) x <- c(1:10) numd1 <- nlmixrGill83(func1, x) exact <- 10*cos(10*x) + exp(-x) cbind(numd1=numd1$df, exact, err=(numd1$df - exact)/exact) sc2.f <- function(x){ n <- length(x) sum((1:n) * (exp(x) - x)) / n } sc2.g <- function(x){ n <- length(x) (1:n) * (exp(x) - 1) / n } x0 <- rnorm(100) exact <- sc2.g(x0) g <- nlmixrGill83(sc2.f, x0) max(abs(exact - g$df)/(1 + abs(exact)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.