I'm trying to estimate the real-world historical density of WTI crude oil spot price, 20days-ahead with respect of the last day of the sample.
I'm using a sample of 130 daily log returns (rend), and I'm following the Stephen Taylor's book ("Asset price dynamicsvolatility and Prediction") methodology. Using a GARCH(1,1), it works, this is the code (I bootstrap 100.000 residuals to compute the same number of price simulation for the target date):
Code: Select all
********GARCH(1,1)*****************
****************************************
calendar(d) 2008:12:2
all 2009:6:2
open data d:\dati\Ricerca\Petrolio\dati_rats5.xls
data(org=obs, format=excel)
table /
garch(p=1,q=1, resids=u, method=bhhh, hseries=h) / rend
compute b0=%beta(1), chat=%beta(2), ahat=%beta(3), bhat=%beta(4)
frml hf = chat+bhat*h{1}+ahat*u{1}**2
SET ustandard 2008:12:2 2009:6:2 = u/SQRT(H)
com span=10
com ndraws=100000
set h 2009:6:2+1 2009:6:2+span =h (2009:6:2)
dec vect returns(ndraws)
do draws=1, ndraws
boot entries 2009:6:2+1 2009:6:2+span 2008:12:2 2009:6:2
set udraw 2009:6:2+1 2009:6:2+span = ustandard(entries)
set u 2009:6:2+1 2009:6:2+span = (h(t)=hf(t)), udraw(t)*sqrt(h(t))
sstats 2009:6:2+1 2009:6:2+span b0+u>>returns(draws)
end do draws
***WTI spot on june 2nd, 2009, is 70.25 $/bbl,***
***so I use that price to calculate spot prices 20days ahead*****
dec vect prices(ndraws)
dec vect priceok(ndraws)
com prices = 70.25*%exp(returns)
do i=1,ndraws
com priceok(i) = %if(prices(i)<0.1, %NA, prices(i))
end do i
set pr 1 ndraws = priceok(t)
SOURCE(NOECHO) DENSITY.SRC
@DENSITY pr 1 1000 XDENS YDENS
SCATTER(STYLE=LINES,VMIN=0.0) 1
# XDENS YDENS
***********************************************************My model doesn't work, i.e. my estimated returns are wrong. I think I included the copnditional mean term in the wrong way.
Could you please help me?this is the code:
Code: Select all
************ GJR(1,1)-M*************************
*****************************************************
***oil price real world density function estimation****
calendar(d) 2008:12:2
all 2009:6:2
open data d:\dati\Ricerca\Petrolio\dati_rats5.xls
data(org=obs, format=excel)
table /
*garch(p=1,q=1, resids=e, asymmetric, method=bhhh,regressors, hseries=h) / rend
*# constant %garchv %mvgavge{1}
***calculation of GJR(1,1)-M model ***
garch(p=1,q=1, resids=e, asymmetric, method=bhhh, regressors, hseries=h) / rend
# constant %garchv
***Rename parameters and add formulas of conditional variance****
*compute gstart=%regstart(), gend=%regend()
com mu=%BETA(1), lambda=%BETA(2), omega=%BETA(3), $
alfa=%BETA(4), alfamin=%BETA(5), beta=%BETA(6)
*frml mf = mu + lambda* sqrt(h)
frml hf = %if(e{1}>0, omega + alfa*e{1}**2 + beta*h{1}, omega + alfa*e{1}**2 + alfamin*e{1}**2 + beta*h{1})
**standardized residuals****
set z 2008:12:2 2009:6:2 = e/sqrt(h)
com span=20
com ndraws=1000
set h 2009:6:2+1 2009:6:2+span =h(2009:6:2)
*set mf2 2009:6:2+1 2009:6:2+span =mf2(2009:6:2)
dec vect returns(ndraws)
*******draws from standard normal, calculate residual "e", compute returns *****
do draws=1, ndraws
boot entries 2009:6:2+1 2009:6:2+span 2008:12:2 2009:6:2
set zsimul 2009:6:2+1 2009:6:2+span = z(entries)
set e 2009:6:2+1 2009:6:2+span = (h(t)=hf(t)), zsimul(t)*sqrt(h(t))
sstats 2009:6:2+1 2009:6:2+span mu+lambda*sqrt(h)+e>>returns(draws)
end do draws
dis returnsthe xls dataset is attached. thank you very much!!