Learn R Programming

irtProb (version 1.0)

derivatives: First and Second Derivatives

Description

Three points first and second derivatives numerical approximation used with the m4plEstimateMore function.

Usage

fprime( x, FUN = "FP", h = 0.001, names = paste("x", c(1:length(x)), sep = ""))
 fsecond(x, FUN = "FP", h = 0.001, names = paste("x", c(1:length(x)), sep = ""))

Arguments

x
numeric; vector of values at which the derivation is to be done.
FUN
function; function to derive.
h
numeric; neighbouring value.
names
character; names given to each results. DEFAULT to the existing names of the vector x.

Value

  • fprimenumeric; vector of first derivatives.
  • fsecondnumeric; matrix of second derivatives.

Details

This function could be used for numerical derivation in general, but is dedicated to be used internally by m4plEstimateMore. For other general purposes D, deriv and deriv3 are preferred.

References

Press, W. H., Vetterling, W. T., Teukolsky, S. A. and Flannery, B. P. (2002). Numerical recipees in C++. The art of scientific computing, 2nd edition. Cambridge, United Kingdom: Cambridge University press. Yakowitz, S. and Szidarovszky, F. (1986). An introduction to numerical computations. New York, New Jersey: MacMilla.

See Also

D, deriv and deriv3

Examples

Run this code
## .....................................
 test  <- function(x) 2*x+5
  test(   x=0)
  fprime( x=0, FUN=test)
  fsecond(x=0, FUN=test)
## .....................................
 test2 <- function(x) 2*(x[1]*x[2])+5
  test2(  x=c(0,0))
  fprime( x=c(0,0), FUN=test2)
  fsecond(x=c(0,0), FUN=test2)

Run the code above in your browser using DataLab