How to optimize the parameters in fillgaps function?

4 views (last 30 days)
I would like to use fillgaps function and I tried with my data but the results were not good. I would like to change the number of samples to use in the estimation and also would like to change the model order which is the order of autoregressive model .I have done with different numbers but I was wondering if there is a way to try with different range of data to get the optimal number of model order and samples(parameters in an autoregressive model). Thanks in advance for any advice
  4 Comments
John D'Errico
John D'Errico on 10 Aug 2016
To be honest, I'd just use my own inpaint_nans, which will replace the NaN elements with smoothly interpolated elements. Of course, if your time series is noisy, then you are best off using a tool that will do smoothing. Inpaint_nans will try to use the data to interpolate, but if there is noise, then the interpolant will be bumpy near the edges of the holes. So I'd not bother with inpaint_nans on a noisy series.
The problem with telling you what to do is the parameters will be problem dependent, and we don't see your data. Nor do we know what was unsatisfactory about the results. My guess is your data is noisy. If it was smooth, then almost anything would work well.
Sadly, I don't think there is some simple formula to know what parameters to use. If there was, the author would have used it.
You might get a better answer if you are willing to post some data, and show how you called fillgaps. Then say what you were unhappy with about the results as you used it.
Rita
Rita on 12 Aug 2016
Thanks John.I have used your helpful function but unfortunately as you mentioned my data is very noisy so if I use cross validation the R2 is around 0.15 which is not a desirable R2 for interpolation of these data.I used fillgaps(data) without any order and maximum length which was calculated based on the all data.

Sign in to comment.

Answers (1)

Greg Dionne
Greg Dionne on 21 Oct 2016
Edited: Greg Dionne on 21 Oct 2016
I find the default values work for me; but sometimes if I have a big signal with lots of missing values, limiting the length of the regression is helpful if all I want is a quick answer. Ideally the length would be just enough to cover the portion of the signal that has a constant AR model. If I'm missing a portion of a slowly varying oscillation, I use a larger value to cover a few cycles of it. If instead I'm missing just a portion of a decaying signal, then I keep the length to be within the decaying portion.
As for order, that can vary. I often start low at first, then increase. Most of the audio clips I tested tended to top out around an order of 200.
This example tries to explain what's going on under the hood.
If you're looking at something that can just interpolate a couple of points that aren't oscillating much (if at all), then take a look at fillmissing.
Let us know what you tried and share your data if you can.

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!