How to calculate first derivative of time series

alexmulo picture alexmulo · Dec 29, 2012 · Viewed 31.1k times · Source

I would calculate the first derivative (dpH/dtime) of time series using two variables, time and pH.

Are there any kind of functions to do this in R or should I compute an extra function to do this?

Answer

G. Grothendieck picture G. Grothendieck · Dec 29, 2012

Assuming pH and time are plain vectors try this:

library(pspline)
predict(sm.spline(time, pH), time, 1)