I have some data which I would like to fit with a model. For this example we have been using LOESS smoothing (<1.000 observations). We applied LOESS smoothing using the geom_smooth()
function from the ggplot
package. So far, so good.
The next step was to acquire a first derivative of the smoothed curve, and as far as we know this is not possible to extract from geom_smooth()
. Thus, we sought to manually create our model using loess()
and use this to extract our first derivative from this.
Strangely however, we observed that the plotted geom_smooth()
curve is different from the manually constructed loess()
curve. This can be observed in the figure which is shown underneath; in red the geom_smooth()
and in orange the loess()
function.
If somebody would be interested, a minimal working reproducible example can be found here.
Would somebody be able to pinpoint why the curves are different? Is this because of the optimization settings of both curves? In order to acquire a meaningful derivative we need to ensure that these curves are identical.