* * Example 7.6 from pp 313-314 * open data d-ibmln98.dat data(format=free,org=columns) 1 9190 ibmlog * nonlin k alpha beta * * Get series of minima over 63 period windows. MVSTATS will compute these over * moving overlapping windows. The SAMPLE instruction is used to pull out every * 63rd element. It defines %NOBS as the number of data points extracted. * compute n=63 mvstats(min=mins,max=maxs,span=n) ibmlog sample(smpl=%clock(t,n)==n) mins / r 1 compute gend = %nobs compute alpha=.8,beta=-2.0,k=-.2 * * Because the GEV distribution is designed for modelling maximum values, we flip * signs on both r and beta to transform the minimum problem to a maximum problem. * frml gevmin = %loggevdensity(-r,k,-beta,alpha) maximize gevmin 1 gend * * Similarly, the beta needs to be sign-flipped in inverting the GEV distribution * to get a left tail. * compute var01=%invgev((1-.01)**n,k,-beta,alpha) compute var05=%invgev((1-.05)**n,k,-beta,alpha) disp "1% VaR with n=63" -var01 disp "5% VaR with n=63" -var05 * * Repeat with n=21 * compute n=21 mvstats(min=mins,max=maxs,span=n) ibmlog sample(smpl=%clock(t,n)==n) mins / r 1 compute gend = %nobs maximize gevmin 1 gend * compute var01=%invgev((1-.01)**n,k,-beta,alpha) compute var05=%invgev((1-.05)**n,k,-beta,alpha) disp "1% VaR with n=21" -var01 disp "5% VaR with n=21" -var05