File: grnd.Rd

package info (click to toggle)
r-cran-optimx 2020-4.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,492 kB
  • sloc: sh: 21; makefile: 5
file content (43 lines) | stat: -rwxr-xr-x 1,000 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
\name{grnd}
\alias{grnd}
\encoding{UTF-8}
\title{A reorganization of the call to numDeriv grad() function.}
\concept{minimization}
\concept{maximization}
\description{
        Provides a wrapper for the numDeriv approximation to the
        gradient of a user supplied objective function \code{userfn}.
}
\usage{
       grnd(par, userfn, ...)
}
\arguments{
 \item{par}{A vector of parameters to the user-supplied function \code{fn}}
 \item{userfn}{A user-supplied function }
 \item{...}{Other data needed to evaluate the user function.}
}
\details{
  The Richardson method is used in this routine.
}
\value{
  \code{grnd} returns an approximation to the gradient of the function userfn
}
\examples{
cat("Example of use of grnd\n")
require(numDeriv)
myfn<-function(xx, shift=100){
    ii<-1:length(xx)
    result<-shift+sum(xx^ii)
}
xx<-c(1,2,3,4)
ii<-1:length(xx)
print(xx)
gn<-grnd(xx,myfn, shift=0)
print(gn)
ga<-ii*xx^(ii-1)
cat("compare to\n")
print(ga)
}
\keyword{nonlinear}
\keyword{optimize}