I have a similar problem .
Here are functions I know that work properly
## PAnnuity function definition
PAnnuity <- function(A,y,m,n)
{
  f<-(A/(y/m))*(1-1/((1+y/m)^n))
}

##BondPrice function
BondPrice <- function(c,y,m,n)
{
  B <-100
  f<-PAnnuity((c/m)*B,y,m,n) + B /((1+y/m)^n)
}


My function of question is which uses the latter function is
Co <- function(c,y,m,n)
{
  f<- D(D(as.expression(BondPrice(c,y,m,n)),"y"),"y")/BondPrice(c,y,m,n)
}

when I test it using 
convexity <- C0(0.09, 0.10, 2, 10)
>[1] 0.

I believe it is passing the parameters and taking the derivative of a
constant. 
How do I get the 2nd Derivative and then pass the parameters for evaluation.

Thanks



--
View this message in context: 
http://r.789695.n4.nabble.com/first-and-second-derivative-calculation-tp1126069p4645388.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to