Time Series modeling/Predicting for GARCH

2 visualizaciones (últimos 30 días)
Sherien Hassan
Sherien Hassan el 3 de Mayo de 2020
Respondida: Peter Perkins el 5 de Mayo de 2020
Hello! I am new to matlab and my goal was to predict using a GARCH Model. I currently understand up to how to model using the econometirc modeler for Garch but I beleive my dates data is not in the correct format to be used for this time series application. Attach is my data and below is the various codes I tried.
data_table=readtable('collide.csv');
data_timetable=table2timetable(data_table);
TF=istimetable(data_timetable) #TF=logical 1
Although the issue with the above code was that it changed my date's year to the below.
01/01/14 #before code
01/01/0014 #aftercode
My goal was to follow exactly what the following video has done but when I try to run
time=datetime(collide(;,1),'ConvertFrom','datenum');
#Error using datetime (line 586)
Input data must be one numeric
matrix when converting from a
different date/time representation.
I thought this may have something to do with the fact that my class is chr but I am too much a newbie to matlab so I am unsure what is the next step to take.

Respuestas (1)

Peter Perkins
Peter Perkins el 5 de Mayo de 2020
You were on the right track, it's just that you file contains two-digit year timestamps, and you need to specify that. Pragmatically, you could have just done this:
>> t = readtable('collide.csv');
>> head(t)
ans =
8×2 table
date pedestrian
__________ __________
01/01/0014 399
01/02/0014 603
01/03/0014 423
01/04/0014 418
01/05/0014 320
01/06/0014 518
01/07/0014 491
01/08/0014 616
>> t.date = t.date + calyears(2000);
>> head(t)
ans =
8×2 table
date pedestrian
__________ __________
01/01/2014 399
01/02/2014 603
01/03/2014 423
01/04/2014 418
01/05/2014 320
01/06/2014 518
01/07/2014 491
01/08/2014 616
but you can also use detectImportOptions to fix the problem before it happens. I'll show using readtimetable; in MATLAB releases before R2019b (I think) you can use readtable and then table2timetable:
>> opts = detectImportOptions('collide.csv');
>> opts = setvaropts(opts,"date","InputFormat",'MM/dd/yy');
>> tt = readtimetable('collide.csv',opts); head(tt)
ans =
8×1 timetable
date pedestrian
________ __________
01/01/14 399
01/02/14 603
01/03/14 423
01/04/14 418
01/05/14 320
01/06/14 518
01/07/14 491
01/08/14 616
The datetimes in that timetable have the same format as in your file; I'd suggest setting the format to something else:
>> tt.date.Format = 'dd-MMM-yyyy'; head(tt)
ans =
8×1 timetable
date pedestrian
___________ __________
01-Jan-2014 399
02-Jan-2014 603
03-Jan-2014 423
04-Jan-2014 418
05-Jan-2014 320
06-Jan-2014 518
07-Jan-2014 491
08-Jan-2014 616
I'm not sure what you need to do after that. The error you got from
time=datetime(collide(;,1),'ConvertFrom','datenum')
is because collide(;,1) is a table (timetable?). That input would need to be numeric, collide.date would have worked, but I recommend that you stay away from datenums. datenum and datetime don't mix, and datetime likely does everything you need.

Categorías

Más información sobre Conditional Variance Models en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by