I recently assisted a physicist with a simple data analysis issue. She had taken a series of measurements with an instrument at varying levels of some setting $\Omega$. The consecutive data points should be noisy about an underlying smooth curve. The physicist wanted to estimate the derivative of this curve at her data points.

Even without assuming any simple parametric structure to the curve, we can achieve this quite easily by using R’s built-in smooth.spline function.

The data has three columns: the predictor variable $\Omega$, and two columns (corresponding to real and imaginary parts) of response variables. The different values of $\Omega$ are spaced out evenly on a logarithmic scale. By log-transforming these $\Omega$ values, we can get evenly spaced data points; this will make the spline fit work better.

Now, the predict.smooth.spline method can give us the derivative of the fit curve at our chosen values. However, because of our natural logarithm transformation, these will be the derivatives with respect to $\log \Omega$. To get the derivatives with respect to $\Omega$, we simply need to divide these derivatives by $\Omega$ because

The physicist will be gathering much more data of this type. The following R script (named ORIspline.R) will allow her to compute the derivative estimates easily on that future data.

Example command line usage: Rscript ORIspline.R NaCl_Omega.ReZ.ImZ.csv

Notice that the name of the file to be analyzed is passed in as a command-line parameter.