1%均數-變異數法
Gretl 指令:
#1%mean-variance
#open file b-g
open b-g
#At first time should be do this ==>>Gern VaR
series VaR=NA
#genr variable
smpl 1 1900
#loop this fomula
loop for j=1901..1974
scalar W=1000000
scalar c_01=critical(z,0.01)
scalar sigma=sd(Y)
#let K=last one+1-----
scalar K=$t2+1
#cal. VaR----------
VaR[K]=W*c_01*sigma/100
#sample (1+1) (1900+1)--------
smpl +1 +1
end loop
smpl full
結果:
計算出各期的風險值如下
1901 11093.40
1902 11093.23
1903 11093.86
1904 11094.48
1905 11094.38
1906 11093.94
1907 11094.89
1908 11095.28
1909 11095.46
1910 11094.52
1911 11091.05
1912 11090.44
1913 11090.39
1914 11090.38
1915 11090.46
1916 11090.53
1917 11090.67
1918 11090.85
1919 11092.55
1920 11092.59
1921 11093.68
1922 11093.66
1923 11092.34
1924 11093.57
1925 11093.33
1926 11093.13
1927 11093.59
1928 11093.23
1929 11093.87
1930 11093.58
1931 11093.49
1932 11091.24
1933 11091.08
1934 11089.44
1935 11088.56
1936 11078.68
1937 11056.21
1938 11051.41
1939 11038.90
1940 11035.78
1941 11033.98
1942 11033.67
1943 11033.09
1944 11018.85
1945 11018.70
1946 11013.14
1947 11004.82
1948 11005.48
1949 11004.83
1950 11010.96
1951 11012.28
1952 11009.92
1953 11009.36
1954 11008.09
1955 11007.26
1956 11008.65
1957 11008.42
1958 11006.78
1959 11005.27
1960 11005.09
1961 11004.59
1962 11002.56
1963 11000.02
1964 11000.70
1965 11001.61
1966 11003.87
1967 11004.04
1968 11003.98
1969 11004.12
1970 11006.85
1971 11007.22
1972 11007.22
1973 11006.97
1974 11007.53
1%歷史模擬法
Gretl 指令:
#1% historical simulation
#open file b-g
open b-g
#At first time should be do this ==>>Gern VaR
series VaR1=NA
#genr variable
smpl 1 1900
#loop this fomula
loop for j=1901..1974
scalar W=1000000
scalar c_01=quantile(Y,0.01)
#scalar sigma=sd(Y)
#let K=last one+1-----
scalar K=$t2+1
#cal. VaR----------
VaR1[K]=-W*c_01/100
#sample (1+1) (1900+1)--------
smpl +1 +1
end loop
smpl full
結果:
1901-1974的風險值均為14609.50
1%歷史模擬法
Gretl 指令:
#5% historical simulation
#open file b-g
open b-g
#At first time should be do this ==>>Gern VaR
series VaR1=NA
#genr variable
smpl 1 1900
#loop this fomula
loop for j=1901..1974
scalar W=1000000
scalar c_01=quantile(Y,0.05)
#scalar sigma=sd(Y)
#let K=last one+1-----
scalar K=$t2+1
#cal. VaR----------
VaR1[K]=-W*c_01/100
#sample (1+1) (1900+1)--------
smpl +1 +1
end loop
smpl full
結果:
計算出各期的風險值如下
1901 8431.978
1902 8431.978
1903 8431.978
1904 8431.978
1905 8431.978
1906 8431.978
1907 8431.978
1908 8431.978
1909 8431.978
1910 8431.978
1911 8431.978
1912 8431.978
1913 8431.978
1914 8431.978
1915 8431.978
1916 8431.978
1917 8431.978
1918 8431.978
1919 8431.978
1920 8431.978
1921 8431.978
1922 8431.978
1923 8431.978
1924 8431.978
1925 8431.978
1926 8431.978
1927 8431.978
1928 8431.978
1929 8431.978
1930 8431.978
1931 8431.978
1932 8431.978
1933 8431.978
1934 8431.978
1935 8431.978
1936 8431.978
1937 8420.188
1938 8420.188
1939 8380.058
1940 8380.058
1941 8380.058
1942 8380.058
1943 8380.058
1944 8355.639
1945 8355.639
1946 8355.639
1947 8353.833
1948 8353.833
1949 8353.833
1950 8380.058
1951 8380.058
1952 8380.058
1953 8380.058
1954 8380.058
1955 8380.058
1956 8380.058
1957 8380.058
1958 8380.058
1959 8380.058
1960 8380.058
1961 8380.058
1962 8380.058
1963 8380.058
1964 8380.058
1965 8380.058
1966 8380.058
1967 8380.058
1968 8380.058
1969 8380.058
1970 8380.058
1971 8380.058
1972 8380.058
1973 8380.058
1974 8380.058