1)
Daily dates
I have managed
to read in
the IRREGULAR dates
data(format=prn,nolabels,org=columns,top=2) 1 %allocend() year month day close
cal(julian=%julianfromymd(year,month,day))
having converted
the dates in Excel from
10/09/1998 123.456
to
1998 9 10 123.456
via year() month() day() and concatenating.
Isn't there
a way
to read in
the dates in
the original format 10/09/1998 in RATS, and then converting?
For TOOS forecasting I do not know
the IRREGULAR business daily days ahead. If
the last date T is 01/09/2023 in
the data file, it
would be very useful
to display T repeated in
the ENTRIES in
a graph for multistep ahead TOOS forecasts as
ENTRY
01/09/2023+1
01/09/2023+2
etc etc
01/09/2023+50 (say)
i.e. anchored on
the last date, instead of having just
the last date repeated 01/09/2023, TOOS times.
2)
Log returns
There are many reasons why log rets vs simple returns are used in data analysis:
- log returns combine linearly over time.
-
the log function suppresses big positive values while emphasizing small negative values.
- log rets are more symmetric then simple rets.
- etc
According
to Tsay AFTS(2010):
Since log returns correspond approximately
to percentage changes in value of
a financial asset, we use log returns in data analysis.
But doesn't say
exactly why in VaR?
And further says:
The dollar amount of VaR is then
the cash value of
the financial position times
the VaR of
the log
return series.
That is, VaR = Value × VaR(of log returns).
If necessary, one can also use
the approximation VaR = Value × [exp(VaR of log returns) − 1].
But
the unlogged VaR ought
to be standard? Investors are interested in
actual monetary terms, not
a log
return.
Thus, instead of VaR being
set VaR ibegin+1 iend+1 = -%invnormal(.01)*fmean*value
The dollar amount of VaR can be approximated by
set VaR ibegin+1 iend+1 = (exp(-%invnormal(.01)*fmean)-1)*value
and instead of Expected Shortfall being
set ES ibegin+1 iend+1 = fmean*%density(%invnormal(.99))/.01 * value
The dollar amount of ES can be approximated by
set ES ibegin+1 iend+1 = exp((fmean*%density(%invnormal(.99))/.01)-1)*value
Correct?
And, shouldn't
the dollar
unlogged amount be displayed in exceedence plots? But log returns are more symmetric vs. simple returns, and is that
the (
only) reason why can VaR can be minusVaR in
the graphs, hence computing violation ratio's? Also there's consistency. It's standard practice for GARCH models
to be based on log returns not simple returns?
3) For
one-step ahead forecasts, which are deterministic, why do more than comp ndraws=1 as h is
the same regardless? As e.g. within
the draw loop if comp draws=5 (say)
disp hdraws(t)
0.00765 0.00000 0.00000 0.00000 0.00000
0.00765 0.00765 0.00000 0.00000 0.00000
0.00765 0.00765 0.00765 0.00000 0.00000
0.00765 0.00765 0.00765 0.00765 0.00000
0.00765 0.00765 0.00765 0.00765 0.00765
4)
Multistep head forecasts
As with SKIPSAVE in FORECAST or
compute rhat12(regend+12)=rhat(regend+12)
How do I gather
the nth step ahead multistep forecast within
the t1 loop?
Code: Select all
*===============================
compute ndraws=10000
compute nsteps=50
*===============================
infobox(action=define,lower=0,upper=(iend-ibegin),progress) "egarchbootstrap Model Backtest"
do t1 = 0, (iend-ibegin)
*
garch(p=1,q=1,exp,asymmetric,hseries=h,noprint,METHOD=BFGS) istart+t1 ibegin+t1 dlogdm
*
if (%converged == 0); garch(p=1,q=1,exp,asymmetric,hseries=h,print,METHOD=BHHH) istart+t1 ibegin+t1 dlogdm
if (%converged == 0); garch(p=1,q=1,exp,asymmetric,hseries=h,print,METHOD=SIMPLEX) istart+t1 ibegin+t1 dlogdm
if (%converged == 0); garch(p=1,q=1,exp,asymmetric,hseries=h,print,METHOD=GENETIC) istart+t1 ibegin+t1 dlogdm
if (%converged == 0); garch(p=1,q=1,exp,asymmetric,hseries=h,print,METHOD=ANNEALING) istart+t1 ibegin+t1 dlogdm
if (%converged == 0); garch(p=1,q=1,exp,asymmetric,hseries=h,print,METHOD=GA) istart+t1 ibegin+t1 dlogdm
if (%converged == 0); garch(p=1,q=1,exp,asymmetric,hseries=h,print,METHOD=EVALUATE) istart+t1 ibegin+t1 dlogdm
*
if (%converged == 0); disp 'Fail'
*
compute c=%beta(2),a=%beta(3),b=%beta(4),d=%beta(5)
compute gstart=istart+t1,gend=ibegin+t1
*
set stdu = %resids/sqrt(h)
*
compute bstart=gend+1,bend=gend+nsteps
set h bstart bend = %na
*
gset hdraws bstart bend = %zeros(ndraws,1)
*
* Compute the one-step bootstrap forecast for the variance
*
do draw=1,ndraws
boot entries bstart bend gstart gend
*
set stdu bstart bend = h=sqrt(exp(c+b*log(h{1})+a*abs(stdu{1})+d*%max(stdu{1},0.0))),stdu(entries(t))
do t=bstart,bend
compute hdraws(t)(draw)=h(t)
end do t
end do draw
*
infobox(current=t1) "Model converged "+%converged
end do t1
infobox(action=remove)