Skip to content
Prev 226561 / 398500 Next

numerical derivative R help

Please do not do multiple postings.

You do not need numerical derivative, but a refresher course in calculus.

fitterma.deriv <- function(xtime) {

a <- -0.09144115

b <- -0.01335756

c <- -2.368057

d <- -0.00600052

deriv <- b * exp(a + b*xtime) + d * exp(c + d * xtime)
return(deriv)

}

require(numDeriv)

xtime <- seq(0, 1, length=100)

deriv.exact <- fitterma.deriv(xtime)

deriv.num <- grad(x=xtime, func=fitterma)
[1] TRUE
Hope this is helpful,
Ravi.

____________________________________________________________________

Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvaradhan at jhmi.edu


----- Original Message -----
From: Parminder Mankoo <pkmankoo09 at gmail.com>
Date: Tuesday, July 6, 2010 7:03 pm
Subject: [R] numerical derivative R help
To: r-help at r-project.org