Python: Cubic Spline Regression for a time series data
Asked Answered
P

1

-1

I have the data as shown below. I want to find a CUBIC SPLINE curve that fits the entire data set (link to sample data). enter image description here

Things I've tried so far:

  1. I've gone through scipy's Cubic Spline Functions, but all of them are only able to give results at a single time only, whereas I want a single curve for the entire time range.

  2. I plotted a graph by taking an average of the spline coefficients generated by scipy.interpolate.splrep for a 4 number of knots, but the results were not good and didn't solve my purpose.

Things that can help me:

  1. An idea about how to optimize the number and position of knots for a better fit

  2. If not that, then if someone can help me find the exact polynomial coefficients for the Cubic Splines for a given number of knots.

  3. If someone can suggest a complete way to solve this problem.

Pauly answered 3/6, 2019 at 6:0 Comment(2)
My regression software cannot use this type of image data, can you please post the data itself?Ding
@JamesPhillips I've added a link to sample data set(csv format) in my editPauly
D
1

I made a 3D scatterplot of the data, converting the timestamps to "elapsed time in seconds" from the first timestamp, the image is below. It appears to me that the data has a sort of 3D equivalent of an outlier, here shown as an entire line of data that is considerably below most of the other data. This will make creating a 3D surface fit of any kind difficult.

scatterplot

Ding answered 3/6, 2019 at 14:27 Comment(2)
Thank you for your efforts. Will it be possible to fit the data if the outlier points are removed or some new data without noise is given using your regression software?Pauly
@Abhijeet Yes. I used my open source curve and surface fitting web site zunzun.com to make the 3D scatterplot, and would also use it to make surface fits of the updated data. You can try it directly to see if it does what you want.Ding

© 2022 - 2024 — McMap. All rights reserved.