資料為:Bollerslev and Ghysels exchange rate data
利用歷史模擬法估計(5%之顯著水準)
#產生一個空的資料集(風險值)
series VaR=NA
#樣本內為1-1900筆
smpl 1 1900
#估計1901-1974的風險值
loop for j=1901..1974
#宣告變數
scalar qt=quantile(Y,0.05)
scalar k2=$t2+1
VaR[k2]=-qt
#起始值+1到最後一筆+1做移動視窗
smpl +1 +1
endloop
smpl full
估計結果
1901-1936 0.8431977
1937-1938 0.8420188
1939-1943 0.8380057
1944-1949 0.8353833
1950-1974 0.8380057
利用歷史模擬法估計(1%之顯著水準)
#產生一個空的資料集(風險值)
series VaR=NA
#樣本內為1-1900筆
smpl 1 1900
#估計1901-1974的風險值
loop for j=1901..1974
#宣告變數 只有在此之顯著水準需變動為0.01
scalar qt=quantile(Y,0.01)
scalar k2=$t2+1
VaR[k2]=-qt
#起始值+1到最後一筆+1做移動視窗
smpl +1 +1
endloop
smpl full
估計結果
1901-1974 1.460950
表示一天內,有1%的機率其損失會超過14609.50