shifting a timeseries without lagmatrix
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello, I don't have access to econometric toolbox, I have a time series in datetime format, I need to lag the time series by 7 days. Please help me out how to do so?
Sample time series:
'06-Jan-1911 00:00:00' 425
'07-Jan-1911 00:00:00' 345
'08-Jan-1911 00:00:00' 425
'09-Jan-1911 00:00:00' 317
'10-Jan-1911 00:00:00' 428
'11-Jan-1911 00:00:00' 566
'12-Jan-1911 00:00:00' 515
'13-Jan-1911 00:00:00' 473
'14-Jan-1911 00:00:00' 369
'15-Jan-1911 00:00:00' 330
'16-Jan-1911 00:00:00' 305
'17-Jan-1911 00:00:00' 243
'18-Jan-1911 00:00:00' 256
'19-Jan-1911 00:00:00' 266
'20-Jan-1911 00:00:00' 240
0 Kommentare
Akzeptierte Antwort
KL
am 15 Nov. 2017
Something like this maybe,
%create some data
C = {'06-Jan-1911 00:00:00' 425
'07-Jan-1911 00:00:00' 345
'08-Jan-1911 00:00:00' 425
'09-Jan-1911 00:00:00' 317
'10-Jan-1911 00:00:00' 428
'11-Jan-1911 00:00:00' 566
'12-Jan-1911 00:00:00' 515
'13-Jan-1911 00:00:00' 473
'14-Jan-1911 00:00:00' 369
'15-Jan-1911 00:00:00' 330
'16-Jan-1911 00:00:00' 305
'17-Jan-1911 00:00:00' 243
'18-Jan-1911 00:00:00' 256
'19-Jan-1911 00:00:00' 266
'20-Jan-1911 00:00:00' 240};
%convert it timetable
TT = timetable(datetime(C(:,1)),[C{:,2}].')
now it looks like,
TT =
15×1 timetable
Time Var1
__________ ____
1911-01-06 425
1911-01-07 345
1911-01-08 425
1911-01-09 317
1911-01-10 428
1911-01-11 566
1911-01-12 515
1911-01-13 473
1911-01-14 369
1911-01-15 330
1911-01-16 305
1911-01-17 243
1911-01-18 256
1911-01-19 266
1911-01-20 240
now add 7 days to the time column,
TT.Time = TT.Time+days(7);
now the modified timetable looks like,
TT =
15×1 timetable
Time Var1
__________ ____
1911-01-13 425
1911-01-14 345
1911-01-15 425
1911-01-16 317
1911-01-17 428
1911-01-18 566
1911-01-19 515
1911-01-20 473
1911-01-21 369
1911-01-22 330
1911-01-23 305
1911-01-24 243
1911-01-25 256
1911-01-26 266
1911-01-27 240
is this what you want?
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!