# TimeSeriesInsert for regular series with equal increment breaks regularity

My goal is to combine two time series with common properties and preserve those properties.

Say, we have two monthly series:

dt1 = DateRange[{2001, 1}, {2010, 1}, {1, "Month"}];
dt2 = DateRange[{2001, 2}, {2010, 2}, {1, "Month"}];

v = RandomReal[{0, 1}, Length@dt1]

ts1 = TimeSeries[Transpose[{dt1, v}]]
ts2 = TimeSeries[Transpose[{dt2, v}]]


Both ts1 and ts2 are constructed as Regular: True and Minimum increment: {1, Month}.

However, when I insert one into another:

TimeSeriesInsert[ts1, ts2]


The resulting series is Regular: False and Minimum increment: {28, Days}.

What is the recommended approach to combining two time series into one while preserving their regularity properties?

ps My current (silly) solution takes the TimeSeries objects apart and then reassembles them:

TimeSeriesInsertPreserve[ts1_, ts2_] := Module[
{d1 = ts2["Dates"],
d2 = Complement[ts1["Dates"], ts2["Dates"]]},
TimeSeries[
Sort[
Join[
{#, ts1@#} & /@ d2,
ts2["DatePath"]
]]]]

• When you combine the series, what is supposed to happen with the values (v)? reference.wolfram.com/language/ref/TimeSeriesInsert.html replaces v at t when a new {t,v] is inserted. It seems like TimeSeriesInsert is more geared towards straightforward "editing" of a time series. – FredrikD Feb 14 at 7:41
• @FredrikD, yes, the behavior of TimeSeriesInsert with regards to values is not a problem. My problem is that it changes the properties of the TimeSeries object from that with regular spacing of observations to irregular time series. – iav Feb 14 at 9:50
• I've added screens - hopefully this makes the problem clearer. – iav Feb 14 at 9:53
• noted. another specific workaround is TimeSeriesResample[TimeSeriesInsert[ts1, ts2], "Month"] – Gosia Mar 27 at 21:29