UV garch model forecasts

Discussions of ARCH, GARCH, and related models
ac_1
Posts: 495
Joined: Thu Apr 15, 2010 6:30 am

Re: UV garch model forecasts

Post by ac_1 »

Here's a concrete example using the g10xrate.xlsx file (which I have called g10xrate(dates).xlsx) from here viewtopic.php?p=19829#p19829

Code: Select all

*===============================
OPEN DATA "g10xrate(dates).xlsx"
DATA(FORMAT=XLSX,NOLABELS,ORG=COLUMNS,TOP=2,JULIAN=DATE) / USXJPN USXFRA USXSUI USXNLD USXUK USXBEL USXGER USXSWE USXCAN USXITA
CALENDAR(JULIAN=DATE)

*OPEN DATA "g10xrate(dates).xlsx"
*DATA(FORMAT=XLSX,NOLABELS,ORG=COLUMNS,TOP=2) / USXJPN USXFRA USXSUI USXNLD USXUK USXBEL USXGER USXSWE USXCAN USXITA

*===============================
declare vector[real] hhat_1(%allocend()+1)

*===============================
set p = usxjpn

set lp = log(p)
diff lp / dlp

set y = 100.0*dlp

comp WIN = 6200
compute tstart= 1
compute tend  = WIN

*===============================
do jj = 0, %allocend()-WIN-1

   garch(p=1,q=1,resids=u,hseries=h,print,METHOD=BFGS) tstart+1+jj tend+1+jj y

   *
   * Compute the one-step forecast for the variance
   *
   comp hhat = ( %beta(2) + %beta(3)*u(tend+1+jj)^2 + %beta(4)*h(tend+1+jj) )

   comp hhat_1((tend+1+jj+1)) = hhat

   disp 'obs' WIN+1+1+jj 'GARCH 1-step ahead forecast'  hhat

end do jj

*===============================
SET vhhat_1 WIN+1+1 %allocend()+1 = hhat_1(t)

prin / vhhat_1

graph 1
# vhhat_1
View -> Series Window

Not using the dates -- that's correct.

Code: Select all

Name    Obs  F Dates
vhhat_1  37  U 6202 6238
Using the dates -- that's not correct.

Code: Select all

Name    Obs  F Dates
vhhat_1  37  i 1973:01:02 1973:02:23
However, if I prin and graph the dates are correct 1997:09:17 1997:11:07.

Why is this happening?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: UV garch model forecasts

Post by TomDoan »

The series are correct; the display in the Series window isn't. The Series window was designed for displaying information with standard dates (it was originally for displaying RATS data files) and wasn't adapted to mapped dates, which require a separate "time series" of information with the dates. We're working on it, but it's not a simple fix.
ac_1
Posts: 495
Joined: Thu Apr 15, 2010 6:30 am

Re: UV garch model forecasts

Post by ac_1 »

TomDoan wrote: Thu Nov 06, 2025 8:17 am The series are correct; the display in the Series window isn't. The Series window was designed for displaying information with standard dates (it was originally for displaying RATS data files) and wasn't adapted to mapped dates, which require a separate "time series" of information with the dates. We're working on it, but it's not a simple fix.
Understood - thanks Tom.
ac_1
Posts: 495
Joined: Thu Apr 15, 2010 6:30 am

Re: UV garch model forecasts

Post by ac_1 »

Code: Select all

*===============================
OPEN DATA dat.txt
DATA(FORMAT=PRN,NOLABELS,ORG=COLUMNS) 1 100 DLP SVAR

*===============================
comp SCALE = 100

set ftrigger %allocend()-99 %allocend() = sVaR/SCALE
set trigger %allocend()-99 %allocend() = dlp < -ftrigger
prin / dlp ftrigger trigger

sstats %allocend()-99 %allocend() trigger>>ntrigger
disp ntrigger
table %allocend()-99 %allocend() trigger

set xdots %allocend()-99 %allocend() = %if(trigger==1,dlp,%na)

prin / xdots
trigger and dlp are 100 in length.

xdots should be 100 in length. xdots has the correct values, but the length of xdots is less than 100.

prin / xdots; * is 87

xdots is only from the first trigger==1 is TRUE to the last trigger==1 is TRUE.

and on View -> Series Window is 87 in length.

Why would that be? And how to SET xdots to be 100 in length i.e. including the NA's?
Attachments
dat.txt
(2.46 KiB) Downloaded 62 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: UV garch model forecasts

Post by TomDoan »

You've already done that:

stats xdots 1 100

Statistics on Series XDOTS
Observations                     4      Skipped/Missing                  96
Sample Mean              -0.023320      Variance                   0.000039
Standard Error            0.006266      SE of Sample Mean          0.003133
t-Statistic (Mean=0)     -7.443046      Signif Level (Mean=0)      0.005020
Skewness                 -0.091471      Signif Level (Sk=0)        0.963521
Kurtosis (excess)        -4.870002      Signif Level (Ku=0)        0.586109
Jarque-Bera               3.958399      Signif Level (JB=0)        0.138180

If you ask the program to figure out the length (with STATS or PRINT without the length), it will truncate to start at the first non-NA and truncate at the last non-NA. But if you created it to length 100, it will know that it's length 100 if you try to use the entries. For instance,

?xdots(100)

will properly show NA while

?xdots(500)

will show

##undefined##
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: UV garch model forecasts

Post by TomDoan »

TomDoan wrote: Thu Nov 06, 2025 8:17 am The series are correct; the display in the Series window isn't. The Series window was designed for displaying information with standard dates (it was originally for displaying RATS data files) and wasn't adapted to mapped dates, which require a separate "time series" of information with the dates. We're working on it, but it's not a simple fix.
This has been fixed with 11.1.
Post Reply