Subtract list with part of the same list
TimeSeries
provides a fairly direct approach to this:
data = Import["https://pastebin.com/raw/QCAKwZ2P", "Package"];
dat1 = Select[data, 60 <= First[#] <= 140 &];
dat2 = Select[data, 10 <= First[#] <= 65 &];
ts2 = TimeSeries[dat2] ~TimeSeriesRescale~ {60, 140};
dat3 = {#, #2 - ts2[#]} & @@@ dat1;
ListPlot[{dat1, dat2, dat3}]
See also TimeSeriesResample
.
Addendum
If I follow what you're asking for in the comments, try this:
ts2raw = TimeSeries[dat2];
datX = Array[{#, ts2raw@#} &, Length @ dat1, MinMax[First /@ dat2]];
Closely related but allowing for nonuniform sampling:
{t1, t2} = {dat1, dat2}[[All, All, 1]];
{m1, m2} = MinMax /@ {t1, t2};
ts2 = TimeSeries[dat2];
datY = {#, ts2@#} & /@ Rescale[t1, m1, m2];
Or:
{ts1, ts2} = TimeSeries /@ {dat1, dat2};
times = TimeSeriesRescale[ts1, MinMax @ ts2["Times"]]["Times"];
tsX = TimeSeriesResample[ts2, {times}]
Here's how to get the same result as Mr. Wizard with your interpolation approach (perhaps there is a slight difference in the result, but the idea is the same):
dat1 = Select[data, 60 <= First[#] <= 140 &];
dat2 = Select[data, 10 <= First[#] <= 65 &];
interp1 = Interpolation[dat1];
interp2 = Interpolation[dat2];
rescaled = Quiet@Table[{0, interp2[t]}, {t, Most@Subdivide[10., 65., Length[dat1]]}];
ListLinePlot[{dat1, dat2, dat1 - rescaled}]
ts = TimeSeries @ data;
{window1, window2} = {{60, 140}, {10, 65}};
{ts1, ts2} = TimeSeriesWindow[ts, #] & /@ {window1, window2};
dif12 = ts1 - TimeSeriesRescale[ts2, window1];
ListLinePlot[{ ts, dif12}]