pageselect dailypage 'change this to the name of your dailypage
'create a daycount series. Note this REQUIRES that the daily page be regular D5 (i.e. has every observation monday-friday).
series daycount = @daycount("monday - friday")
'we're going to loop over the years/quarters through our estimation window (note, it can't be for the full sample period due to the number of observations required in the loop). In each quarter we're going to perform a rolling daily forecast of that current quarter
!endyear = @datepart(@now, "YYYY")
!endquarter = @datepart(@now, "Q")
for !y=2008 to !endyear
!lastquarter = 4 'how many quarters we're doing in the year.
if !y = !endyear then
!lastquarter = !endquarter
endif
for !q = 1 to !lastquarter
%currentquarter = @str(!y) + "Q"+@str(!q)
'put a message in the statusbar (bottom left corner of EViews) saying which quarter we're on
statusline Looping through quarter {%currentquarter}
'workout how many days are in current quarter
pageselect quarterlypage ' change this to the name of your quarterly page
!days = @elem(daycount, %currentquarter)
'we're going to do a rolling forecast from the first day of the current quarter onwards. Each iteration of the roll we're going to use 45 days of the daily X variables from current day and previous quarters' GDP + previous quarters' quarterly variables to estimate GDP.
'first we need to calculate the observation number for the start of current quarter on the daily page - we'll need this number later inside the loop, better to calculate it now rather than each time in the loop
pageselect dailypage
!startday = @dtoo(%currentquarter)
pageselect quarterlypage
'start the daily loop
for !d=1 to !days
'!i is the number of days into the quarter we are.
!shift = !days-!d+1
'estimate equation from start of workfile until current quarter
smpl @first {%currentquarter}-1
equation eq_gdp_qoq_nowcast_full_period.midas(fixedlag=45) GDP_Q_TREND_3m_chg C GDP_Q_TREND_3m_chg(-1) ACTIVITY_CURRENT(-1) ACTIVITY_LEADING(-1) INVESTMENT(-1) LABOUR_MARKET(-1) @ au_midas_daily\atwi_final(-!shift) au_midas_daily\gacgb3_final(-!shift)
'forecast current GDP
smpl {%currentquarter} {%currentquarter}
eq_gdp_qoq_nowcast_full_period.forecast gdp_q_trend_3m_chgf
'grab that single quarter forecast value
!forcval = @elem(gdp_q_trend_3m_chgf, %currentquarter)
'switch to daily page and fill in that forecast val for current iteration's day
pageselect dailypage
%currentday = @otod(!startday+!d-1) 'get string representation of current iteration's day
smpl {%currentday} {%currentday}
series gdp_q_trend_3m_chgf = !forcval 'set forecast series to the forecasted value from the quarterly page
pageselect quarterlypage
next
next
next
'now that we have a daily updated forecast of GDP, we'll switch to the daily page and graph it
pageselect AU_MIDAS_daily
smpl @all
show gdp_q_trend_3m_chgf.line