0
$\begingroup$

I download three time series from FRED:

fred = ServiceConnect["FederalReserveEconomicData"]
ffr10 = fred["SeriesData","ID"->{"DFEDTAR"},"Date"  ->{"2006-12-16","2022-01-01"}];
ffr11 = fred["SeriesData","ID"->{"DFEDTARU"},"Date" ->{"2006-12-16","2022-01-01"}];
ffr12 = fred["SeriesData","ID"->{"DFEDTARL"},"Date" ->{"2006-12-16","2022-01-01"}];

and I plot them:

DateListPlot[{ffr10, ffr11, ffr12}]

enter image description here

I would like to add a time point to the blue series (ffr10): {First date of orange series (ffr12), first value of orange series (ffr12)}, so that the lines connect. How can I do it?

$\endgroup$
2
  • 1
    $\begingroup$ I don't have access to FRED (it requires an API key) so I can't reproduce your data. Can you include small portions of the data itself, or a pair of made-up data sets to play with? $\endgroup$
    – MarcoB
    Commented May 16, 2022 at 17:00
  • $\begingroup$ try TimeSeriesInsert[ffr10, First@ffr12["Path"]] or TimeSeriesInsert[ffr10, ffr12]? $\endgroup$
    – kglr
    Commented May 17, 2022 at 12:10

1 Answer 1

2
$\begingroup$

As you did not post some sample data we create 2 time series:

v = {2, 1, 6, 5, 7, 4};
t = {1, 2, 5, 10, 12, 15};
ts1 = TimeSeries[v, {t}];
ts2 = TimeSeries[v, {t + 20}];
ListLinePlot[{ts1, ts2}]

enter image description here

To get the data pairs from a time series you use: timeseries["Path"]. Therefore, we need all the data from ts1 and only the first data pair from ts2. Then we append the first element from ts2 to the data from ts1 and convert this to a new time series:

ts11 = TimeSeries[Append[ts1["Path"], ts2["Path"][[1]]]] ;
ListLinePlot[{ts11, ts2}]

enter image description here

You may want to join both time series to a new one:

ts3 = TimeSeries[Join[ts1["Path"], ts2["Path"]]] ;
ListLinePlot[ts3]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.