1

Let us say I have an output data that is composed of a vector with 10 elements. I interpolated these data via spline interpolation using R command splinefun, this helped me obtain a function interpolation (cubic spline) that can take any real number within the domain x that produces the output f(x) that lies on this spline curve.

My question, from f which is now a function how can we create a derivative function in R? It is like I want to interpolate over the derivatives.

The package numDeriv allowed me to write d_f <- genD(func = f, x = x)$D[1] but this is not helping. I hope someone can help me.

UserX
  • 111
  • 2
  • 1
    Please provide reproducible data. Use `dput()` and paste the results into your question. Also explain what "not helping" means. – dcarlson Sep 24 '22 at 23:12
  • As https://stackoverflow.com/questions/4338900/how-can-i-evaluate-the-derivative-of-a-spline-function-in-r points out, the function returned by `splinefun` already has a `deriv` argument -- see the "Value" section of the help page. – Ben Bolker Sep 24 '22 at 23:14

0 Answers0