How to calculate first derivative of time series

后端 未结 3 649
梦谈多话
梦谈多话 2021-01-31 20:16

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

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-31 21:00

    You might want to start with stats::deriv or diff.ts as Matt L suggested. Just keep in mind what a professor of mine used to tell all his students: numeric differentiation is known as "error multiplier."

    EDIT: To clarify -- what he was warning about was that any noise in your data can throw the derivative estimate way off. It's been said that integration is a low-pass filter and differentiation is a high-pass filter. So, the important thing is to do some smoothing on your data before calculating a derivative. Hence Gabor's excellent suggestion to use predict.spline . But keep in mind that modifying the spline parameters will smooth your data to different levels, so always look at the results to make sure you removed apparent noise but not desired features.

提交回复
热议问题