calculus - R - how do I find the second derivative of a numeric array -


i have array of numeric data (as happens option call prices organized strike).

i'd compute second deriviative in r.

i able fit smooth curve e.g.

call.lo <- loess(mid ~ strike, df.x, model=t) 

but stuck going differentiation.

any appreciated, thanks.

do want discrete second derivative?

 mid <- 1:100; strike <- (1:100)^3 + 2*(1:100)^2 + 1:100 + 5   deriv <- function(x, y) diff(y) / diff(x)  middle_pts <- function(x) x[-1] - diff(x) / 2  second_d <- deriv(middle_pts(mid), deriv(mid, strike))  smooth_second_d <- loess(second_d ~ midpts,    data.frame(second_d = second_d, midpts = middle_pts(middle_pts(mid))), model = t) 

example:

 plot(middle_pts(middle_pts(mid)), deriv(middle_pts(mid), deriv(mid, strike))) 

i see 6x + 4 expected.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -