Dear stata listers,

I'm currently doing an event study using GARCH model to test the effects of certain events on the volatility of stock markets.
After the GARCH model I need to predict the variance. However, my problem is that I need a dynamic prediction and not a one-day-ahead prediction.
The estimation window is t=-500 to t=-1 and the event window: t=0 to t=30. I want the dynamic prediction to start at the day of the event (t=0) using the information set available on t=-1 (the last day of the estimation window)


I'm using stata 15


My statacodes look like:

gen predicted_return=.
gen predicted_variance=.
gen nIndicator = _n
tsset nIndicator
egen id=group(company_id)


forvalues i=2(1)2 { /*note: replace N with the highest value of id */
l id company_id if id==`i' & dif==0
arch ret market_return if id==`i' & estimation_window==1, arch(1) garch(1) nolog
predict p if id==`i'
replace predicted_return = p if id==`i' & event_window==1
drop p
local tInd = nIndicator[dif==0 & id==`i']
predict p if id==`i', variance dynamic(`tInd')
replace predicted_variance = p if id==`i' & event_window==1
drop p
}

However, when I do this the dynamic prediction starts at t-500 whilst it needs to start at t (the day of the event).

and my data is as follows:

date market_return country_id ret set event_date company_id datenum td dif event_window count_event_obs estimation_window count_est_obs predicted_return predicted_variance nIndicator id
26aug2015 2.06% 2 -.0232401 37 02sep2015 84 778 783 -5 0 30 1 500 9892 7
27aug2015 2.11% 2 .0029889 37 02sep2015 84 779 783 -4 0 30 1 500 9893 7
28aug2015 0.46% 2 .0216223 37 02sep2015 84 780 783 -3 0 30 1 500 9894 7
31aug2015 -0.76% 2 .0295807 37 02sep2015 84 781 783 -2 0 30 1 500 9895 7
01sep2015 -2.72% 2 .0182079 37 02sep2015 84 782 783 -1 0 30 1 500 9896 7
02sep2015 0.93% 2 -.0117279 37 02sep2015 84 783 783 0 1 30 0 500 9897 7
03sep2015 0.45% 2 -.0159718 37 02sep2015 84 784 783 1 1 30 0 500 9898 7
04sep2015 -1.68% 2 .003991 37 02sep2015 84 785 783 2 1 30 0 500 9899 7
07sep2015 0.18% 2 .0183392 37 02sep2015 84 786 783 3 1 30 0 500 9900 7
02dec2014 0.35% 2 -.0107188 50 10dec2014 97 597 603 -6 0 30 1 500 11230 8
03dec2014 0.22% 2 -.0087944 50 10dec2014 97 598 603 -5 0 30 1 500 11231 8
04dec2014 -0.18% 2 -.0024023 50 10dec2014 97 599 603 -4 0 30 1 500 11232 8
05dec2014 0.11% 2 .0015828 50 10dec2014 97 600 603 -3 0 30 1 500 11233 8
08dec2014 -0.69% 2 -.0045892 50 10dec2014 97 601 603 -2 0 30 1 500 11234 8
09dec2014 -0.26% 2 -.0043328 50 10dec2014 97 602 603 -1 0 30 1 500 11235 8
10dec2014 -1.37% 2 -.0221322 50 10dec2014 97 603 603 0 1 30 0 500 11236 8
11dec2014 0.04% 2 -.0354491 50 10dec2014 97 604 603 1 1 30 0 500 11237 8
12dec2014 -1.41% 2 -.0096146 50 10dec2014 97 605 603 2 1 30 0 500 11238 8
15dec2014 -1.22% 2 -.0088118 50 10dec2014 97 606 603 3 1 30 0 500 11239 8
16dec2014 0.06% 2 -.0230455 50 10dec2014 97 607 603 4 1 30 0 500 11240 8
17dec2014 1.02% 2 -.0277923 50 10dec2014 97 608 603 5 1 30 0 500 11241 8
30nov2015 -0.35% 2 -.0083918 1587 03dec2015 1634 843 846 -3 0 30 1 500 711735 469
01dec2015 0.93% 2 -.0026178 1587 03dec2015 1634 844 846 -2 0 30 1 500 711736 469
02dec2015 -0.81% 2 -.0009559 1587 03dec2015 1634 845 846 -1 0 30 1 500 711737 469
03dec2015 -1.06% 2 .0099418 1587 03dec2015 1634 846 846 0 1 30 0 500 711738 469
04dec2015 0.99% 2 .0026078 1587 03dec2015 1634 847 846 1 1 30 0 500 711739 469
07dec2015 -0.48% 2 .007341 1587 03dec2015 1634 848 846 2 1 30 0 500 711740 469
08dec2015 -0.94% 2 -.0108091 1587 03dec2015 1634 849 846 3 1 30 0 500 711741 469


How could I make the dynamic prediction I need?

Thank you in advance

Rosa