Skip to main content
3 of 6
added 107 characters in body
Harald
  • 1.6k
  • 1
  • 11
  • 15

piecewise trend reduction

How can I reduce a non-linear trend of some data series if there are parts of "no data", represented by the value 99999? For example:

{{124.55,368.632},
{124.6,281.976},
{124.65,200.952},
{124.7,91.384},
{124.75,-60.424},
{124.8,-282.504},
{124.85,-541.448},
{124.9,-378.76},
{124.95,99999},
{125,99999},
{125.05,99999},
{125.1,99999},
{125.15,99999},
{125.2,99999},
{125.25,99999},
{125.3,99999},
{125.35,265.46},
{125.4,376.75},
{125.45,462.54},...,{178.95,284.46}}

Normally, I am successful reducing the non-linear trend of the data via

lm = LinearModelFit[data, {a, a^2, a^3, a^4, a^5},a];
Do[aha = Last[Take[data, {m, m}]]; y = Last[aha]; 
  x = First[aha]; new[m] = y - lm[x], {m, idim}];

but have no idea how to do the trend-reduction between those data gaps (i.e., outside of the regions with data = 99999). The position of those regions is not constant.

Thanks a lot for each hint, Harald

P.S.: After the reduction is performed, the position of the "no data"-values should be the same as before

Harald
  • 1.6k
  • 1
  • 11
  • 15