Accurate Numerical Derivatives

Methods for calculating (usually) accurate numerical first and second order derivatives. Accurate calculations are done using 'Richardson''s' extrapolation or, when applicable, a complex step derivative is available. A simple difference method is also provided. Simple difference is (usually) less accurate but is much quicker than 'Richardson''s' extrapolation and provides a useful cross-check. Methods are provided for real scalar and vector valued functions.


Known BUGS

o the hessian function in numDeriv does not accept method="simple".

o When method="Richardson", it does not work when r=1, because of subscripting issues. Should fix this such that it does a central difference approximation, without any extrapolation.

Changes in numDeriv version 2016.8-1

o simplification of hessian.default() call to jacobian() and grad() in the case of method 'complex' (pointed out by Andreas Rappold).

o added argument 'side=NULL' in the hessian.default() call to jacobian() and grad() in the case of method 'complex' to ensure proper passing of ... arguments to the function for which the hessian is being calculated (pointed out by Andreas Rappold).

Changes in numDeriv version 2014.2-1

o added argument 'side' to allow one-sided first derivatives (grad and jacobian) for simple and Richardson methods.

o minor documentation improvements.

Changes in numDeriv version 2013.2-1

o updated R dependency from 1.8.1 to 2.11.1 because of complex step derivative dependency on a fix to exponentiation with integers (pointed out by Hans W. Borchers).

o added flag in DESCRIPTION to ByteComple.

Changes in numDeriv version 2012.9-1

o added complex step derivatives (from Ravi Varadhan) and related tests.

o changed method.args to an empty list in the default methods, as the real defaults depend on the approximation, and are documented in details.

Changes in numDeriv version 2012.3-1

o no real changes, but bumping version for new CRAN suitability check.

Changes in numDeriv version 2011.11-2

o fixed genD documentation error for denominator in f" (d^2 rather than 2*d noticed by Yilun Wang)

Changes in numDeriv version 2011.11-1

o updated maintainer email address.

Changes in numDeriv version 2010.11-1

o Added warning in the documentation regarding trying to pass arguments in ... with the same names as numDeriv function arguments.

Changes in numDeriv version 2010.2-1

o Added more graceful failure in the case of NA returned by a function (thanks to Adam Kramer).

Changes in numDeriv version 2009.2-2

o Standardized NEWS format for new function news().

Changes in numDeriv version 2009.2-1

o argument zero.tol was added to grad, jacobian and genD, and is used to test if parameters are zero in order to determine if eps should be used in place of d. Previous tests using == did not work for very small values.

o defaults argument d to grad was 0.0001, but specification made it appear to be 0.1. Specification was changed to make default clear.

o unnecessary hessian.default argument setting was removed (they are just passed to genD which duplicated the setting).

o Some documentation links to [stats]numericDeriv mistakenly called numericalDeriv were fixed.

Changes in numDeriv version 2006.4-1

o First released version.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


2016.8-1.1 by Paul Gilbert, 2 years ago

Browse source code at

Authors: Paul Gilbert and Ravi Varadhan

Documentation:   PDF Manual  

Task views: Numerical Mathematics

GPL-2 license

Imported by ARCensReg, ARpLMEC, AssetCorr, BAMBI, BIGL, BLPestimatoR, BayesianTools, BinaryEPPM, CIAAWconsensus, CensSpatial, CompAREdesign, Countr, CountsEPPM, Disequilibrium, DoubleExpSeq, EKMCMC, EWS, Epi, EstimationTools, ExtDist, ExtremalDep, FENmlm, FMCCSD, GAS, GB2, GB2group, GDINA, GGMncv, GJRM, GPvam, HAC, HDBRR, ICcalib, IPEC, Infusion, IsoriX, LMMstar, LoopDetectR, MIIVsem, MNB, MPTinR, MSGARCH, MixGHD, NFCP, OUwie, PLmixed, PROreg, PSweight, PenIC, PrevMap, ProbitSpatial, Qtools, RJafroc, Rcgmin, Rchoice, RealVAMS, Renext, SGB, SIRE, SIfEK, SPAS, StVAR, StableEstim, SurvRegCensCov, TSMSN, Temporal, ThreeArmedTrials, ThresholdROC, UPCM, VCA, WeMix, activegp, aldvmm, antitrust, apollo, auctionr, automultinomial, bbmle, blackbox, brglm2, chandwich, climwin, clusteredinterference, condGEE, copula, corHMM, corncob, coxphMIC, cta, ctmcd, ctmm, cuRe, discfrail, distributional, durmod, dynr, elasdics, emmeans, equateMultiple, ergMargins, extendedFamily, fastR2, fdapace, fic, finiteruinprob, fishmethods, fixest, flexCWM, flexsurv, frailtyEM, frailtySurv, gamCopula, geex, geoFKF, geostatsp, gim, glmmTMB, glmmsr, gofCopula, grmsem, hierSDR, highfrequency, incidental, indelmiss, inferference, ivtools, kergp, kinematics, lacm, lava, lavaan, lax, lbfgsb3c, lmerTest, lqr, lsbs, marcher, marginaleffects, marked, markophylo, mbmixture, mccmeiv, mecor, merDeriv, metRology, metaSEM, metaplus, mets, mexhaz, mfGARCH, midasr, milr, misclassGLM, misreport, mixl, mkin, mlt, mlt.docreg, momentuHMM, moveHMM, mpath, mrds, multicmp, mvglmmRank, mvord, nlmm, optextras, optimr, optimx, ordinal, pacotest, pbkrtest, phenofit, phytools, pooling, pssm, psychonetrics, ptmixed, robmixglm, robustBLME, rodd, rugarch, sarima, sars, sdprisk, sensR, seqHMM, sfaR, sinar, skewlmm, sklarsomega, slgf, smam, sn, sns, spant, spfrontier, spsur, stabreg, stdReg, stochprofML, surf, survey, tcl, tcpl, tcplfit2, temperatureresponse, tfarima, timereg, touchard, tramME, ttcg, ui, vcrpart, waydown, xmeta.

Depended on by BiProbitPartial, CBPS, CompDist, CompLognormal, DIMORA, DOBAD, HPbayes, OneStep, QRM, SemiMarkov, alabama, bayesDccGarch, bayesmeta, bnormnlr, catIrt, compound.Cox, copCAR, dsm, embryogrowth, fgof, fracprolif, ghyp, glmtoolbox, lcpm, lmeNB, ltbayes, mederrRank, mgpd, mipfp, mixlink, nmw, phenology, rxSeq, sgt, ssym, tbd, turboEM, tvgarch, wnl.

Suggested by BB, DiceKriging, DoseFinding, GauPro, IGP, KFKSDS, LAM, LambertW, OpenMx, ROI, RSSL, SACOBRA, SAMtool, SemiEstimate, SuperGauss, TMB, TestFunctions, VineCopula, aster, cccp, cotram, discSurv, diseq, diversitree, docopulae, emdbook, flacco, gcKrig, glmx, hadron, hesim, hhh4contacts, lavaSearch2, legion, lfe, lme4, metadat, metafor, metarep, miceadds, mlr, msm, nlmrt, nlsr, ohenery, optimParallel, pso, psqn, psychomix, regsem, riskParityPortfolio, riskRegression, rpf, schumaker, smooth, smovie, sna, sparseHessianFD, sphunif, statespacer, stsm, surveillance, torch, tram, ucminf, xtune.

See at CRAN