({{, (RefLink[TimeSeriesThread, paclet:ref/TimeSeriesThread])[f,{(Subscript[tseries, 1]),(Subscript[tseries, 2]),…}]
combines the (Subscript[tseries, i]) using the function f.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[TimeSeriesThread, paclet:ref/TimeSeriesThread]) is used to combine the values of multiple time series.

(RefLink[TimeSeriesThread, paclet:ref/TimeSeriesThread]) can be used for regularly and irregularly spaced time series.

The input for each of the (Subscript[tseries, i]) can be a list of time-value pairs {{(Subscript[t, 1]),(Subscript[x, 1])},{(Subscript[t, 2]),(Subscript[x, 2])},…}, a (RefLink[TimeSeries, paclet:ref/TimeSeries]), (RefLink[EventSeries, paclet:ref/EventSeries]), or (RefLink[TemporalData, paclet:ref/TemporalData]).

All of the (Subscript[tseries, i]) must contain the same number of paths.

(RefLink[TimeSeriesThread, paclet:ref/TimeSeriesThread]) threads pathwise for (Subscript[tseries, i]) with multiple paths.

The collection of paths {(Subscript[tseries, 1]),(Subscript[tseries, 2]),…} can equivalently be given as (RefLink[TemporalData, paclet:ref/TemporalData])[{(Subscript[tseries, 1]),(Subscript[tseries, 2]),…}].

If the times for the (Subscript[tseries, i]) are not equivalent, they are each resampled using the union of their times.

(RefLink[TimeSeriesThread, paclet:ref/TimeSeriesThread]) takes the following option:

OpenersPrimaryExamplesSection(Spacer1)Examples  (16)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Obtain the sum of two time series:

ts1=TimeSeries[{(Subscript[x, 1]),(Subscript[x, 2]),(Subscript[x, 3]),(Subscript[x, 4]),(Subscript[x, 5])},{1}];
ts2=TimeSeries[{(Subscript[y, 1]),(Subscript[y, 2]),(Subscript[y, 3]),(Subscript[y, 4]),(Subscript[y, 5])},{1}];

TimeSeriesThread[Total,{ts1,ts2}]["Path"]

Combine two time series using a generic function f:

ts1=TimeSeries[{(Subscript[x, 1]),(Subscript[x, 2]),(Subscript[x, 3]),(Subscript[x, 4]),(Subscript[x, 5])},{1}];
ts2=TimeSeries[{(Subscript[y, 1]),(Subscript[y, 2]),(Subscript[y, 3]),(Subscript[y, 4]),(Subscript[y, 5])},{1}];

TimeSeriesThread[f,{ts1,ts2}]["Path"]

Compute the differences between two financial time series:

goog=FinancialData["GOOGL","2012"];
appl=FinancialData["AAPL","2012"];

DateListPlot[TimeSeriesThread[First[#]-Last[#]&,{goog,appl}]]

Find the average path:

data=RandomFunction[WienerProcess[],{0,1,.001},100];

ListLinePlot[data,PlotStyle->Thin]

TimeSeriesThread[Mean,data];

ListLinePlot[%]

OpenersExampleSection1(Spacer1)Scope  (7)

OpenersExampleSubsection0(Spacer1)Basic Uses  (3)

Total 10 simulated (RefLink[BernoulliProcess, paclet:ref/BernoulliProcess]) paths:

td=RandomFunction[BernoulliProcess[1/4],{25},10];

sum=TimeSeriesThread[Total,td];

ListPlot[sum,Filling->Axis]

Compute a min-max envelope for some process paths:

data=RandomFunction[WienerProcess[],{0,1,.01},10^3];

max=TimeSeriesThread[Max,data];
min=TimeSeriesThread[Min,data];

ListLinePlot[{max,min},PlotLegends->{"max","min"}]

Create a 95% confidence envelope for some process paths:

data=RandomFunction[WienerProcess[],{0,1,.01},500];

Compute a time series of means μ(t) and standard deviations σ(t):

μ=TimeSeriesThread[Mean,data];
σ=TimeSeriesThread[StandardDeviation,data];

A 95% confidence interval for a normal is given {μ(t)-1.95` σ(t),μ(t)+1.95` σ(t)}:

conf=TimeSeriesThread[{#[[1]]-1.95#[[2]],#[[1]]+1.95#[[2]]}&,{μ,σ}];

Show[ListLinePlot[data,PlotStyle->Opacity[.1]],ListLinePlot[conf,PlotStyle->Black]]

OpenersExampleSubsection1(Spacer1)Data Types  (4)

Obtain the sum of two time series given by time-value pairs:

ts1={{1,a},{2,b},{3,c}};
ts2={{1,d},{2,e},{3,f}};

TimeSeriesThread[Total,{ts1,ts2}]

Obtain the difference between two (RefLink[TimeSeries, paclet:ref/TimeSeries]):

ts1=TimeSeries[{(Subscript[x, 1]),(Subscript[x, 2]),(Subscript[x, 3]),(Subscript[x, 4]),(Subscript[x, 5]),(Subscript[x, 6])}];
ts2=TimeSeries[{(Subscript[y, 1]),(Subscript[y, 2]),(Subscript[y, 3]),(Subscript[y, 4]),(Subscript[y, 5]),(Subscript[y, 6])}];

TimeSeriesThread[Subtract@@#&,{ts1,ts2}]["Path"]

Find the standard deviation of various paths in (RefLink[TemporalData, paclet:ref/TemporalData]):

data=RandomFunction[WienerProcess[],{0,1,.001},100]

ListLinePlot[data,PlotStyle->Thin]

TimeSeriesThread[StandardDeviation,data];

ListLinePlot[%]

Find the maximum values between two (RefLink[EventSeries, paclet:ref/EventSeries]):

es1=EventSeries[];

es2=EventSeries[];

max=TimeSeriesThread[Max,{es1,es2}];

ListPlot[#,Filling->Axis]&/@{es1,es2,max}

OpenersExampleSection2(Spacer1)Options  (1)

OpenersExampleSubsection2(Spacer1)Resampling Method  (1)

Combine two time series with mismatched times:

ts1=TimeSeries[{1,3,5,7,9},{1}];
ts2=TimeSeries[{2,3,4,5,6},{{1,1.5,3.5,4,5}}];

Use zero-order interpolation:

int0=TimeSeriesThread[Total,{ts1,ts2},ResamplingMethod->"Interpolation"];

int0//Normal

Use interpolation order 1:

int1=TimeSeriesThread[Total,{ts1,ts2},ResamplingMethod->{"Interpolation",InterpolationOrder->1}];

int1//Normal

ListLinePlot[{int0,int1},PlotLegends->{"interpolation order 0","interpolation order 1"}]

OpenersExampleSection3(Spacer1)Applications  (4)

Simulate a jump-diffusion process:

tspec={0,3,.01};
jump=RandomFunction[PoissonProcess[3],tspec];
diff=RandomFunction[WienerProcess[1.9,1],tspec];
data=TimeSeriesThread[Total,{jump,diff}];

ListPlot[{data,jump,diff},PlotStyle->{Thick,Dashed,Dashed},PlotLegends->{"jump-diffusion","jumps","diffusion"}]

Generate a time series of the Sun's position and the Moon's position over a period of two months:

sunpos=SunPosition[DateRange[Today-Quantity[2,"Months"],Today,{12,"Hour"}],CelestialSystem->"Equatorial"]

moonpos=MoonPosition[DateRange[Today-Quantity[2,"Months"],Today,{12,"Hour"}],CelestialSystem->"Equatorial"]

Define a function to compute the angular distance between two objects on a sphere:

AngularDistance[{ϕ1_,θ1_},{ϕ2_,θ2_}]:=InverseHaversine[Haversine[ϕ1-ϕ2]+Cos[ϕ1]Cos[ϕ2]Haversine[θ1-θ2]]/Degree

Find the time series for the angular distance between the Sun and the Moon:

angdist=TimeSeriesThread[AngularDistance[First[#],Last[#]]&,{sunpos,moonpos}]

Visualize the angular distance:

DateListPlot[angdist]

Study male unemployment in France:

MaleLaborForce=EntityValue[Entity["Country","France"],EntityProperty["Country","LaborForce",{"Date"->All,"Gender"->"Male"}]];

Unemployment rates:

Rates=EntityValue[Entity["Country","France"],EntityProperty["Country","UnemploymentRate",{"Date"->All,"Gender"->"Male"}]];

Rates["Values"]

Convert rates to fractions:

MaleUnemploymentRate=QuantityMagnitude[Rates]/100;

MaleUnemploymentRate["Values"]

Male unemployment is the corresponding fraction of the male labor force:

MaleUnemployment=TimeSeriesThread[Times@@#&,TimeSeriesResample[TemporalData[{MaleLaborForce,MaleUnemploymentRate}],"Intersection"]];

DateListPlot[MaleUnemployment,FrameLabel->Automatic]

Create a lunar calendar in which the background color depends on the fraction of the Moon illumination:

dates=DateRange[DateObject[{2014,1,1,12}],DateObject[{2014,1,31,12}],1];

mp=MoonPhase[dates,"Icon"];
sf=MoonPhase[dates,"Fraction"];

Create a new event series with vector values composed of icons and fractions:

phases=TimeSeriesThread[#&,{mp,sf}]

Visualize the lunar calendar:

Labeled[Grid[Partition[Framed[Labeled[ImageResize[First[#2],45],DateString[#1,{"DayNameShort"," ","DayShort"}]],Background->Lighter[ColorData["StarryNightColors",Last[#2]],.3]] & @@@ phases["Path"], 7, 7, 4, ""], Frame -> All,Spacings->{0,0}], "January 2014", Top]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[MovingMap, paclet:ref/MovingMap])  ▪  (RefLink[TimeSeriesAggregate, paclet:ref/TimeSeriesAggregate])  ▪  (RefLink[TimeSeriesResample, paclet:ref/TimeSeriesResample])  ▪  (RefLink[RegularlySampledQ, paclet:ref/RegularlySampledQ])  ▪  (RefLink[MinimumTimeIncrement, paclet:ref/MinimumTimeIncrement])  ▪  (RefLink[TimeSeriesShift, paclet:ref/TimeSeriesShift])  ▪  (RefLink[TimeSeriesRescale, paclet:ref/TimeSeriesRescale])  ▪  (RefLink[TimeSeriesMap, paclet:ref/TimeSeriesMap])  ▪  (RefLink[TimeSeriesMapThread, paclet:ref/TimeSeriesMapThread])  ▪  (RefLink[TimeSeriesInsert, paclet:ref/TimeSeriesInsert])  ▪  (RefLink[TimeSeriesModelFit, paclet:ref/TimeSeriesModelFit])  ▪  (RefLink[TimeSeriesWindow, paclet:ref/TimeSeriesWindow])  ▪  (RefLink[TemporalData, paclet:ref/TemporalData])  ▪  (RefLink[TimeSeries, paclet:ref/TimeSeries])  ▪  (RefLink[EventSeries, paclet:ref/EventSeries])  ▪  (RefLink[ResamplingMethod, paclet:ref/ResamplingMethod])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Time Series Processing, paclet:guide/TimeSeries])}})}})