-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgretl_code_replication.inp
138 lines (109 loc) · 3.63 KB
/
gretl_code_replication.inp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
clear # clear memory
set verbose off # avoid printing commands
# Define a string variable for the URL
string url = "https://scm.darnold.org/atecon/gretl_aer/raw/master"
# Load the monthly series
open "@url/data_unrate.xls" --rowoffset=10 --preserve
# Define the data structure
setobs 12 1948:01 --time-series
# Transform the monthly series to quarterly
dataset compact 4
# Set the sample in line with the series being appended
smpl 1948:1 2018:2
# Append the real GDP series
append "@url/data_gdp.xls" --rowoffset=10
# Drop the series 'observation_date'
delete observation_date
# Store the two time-series in native Gretl data format (*.gdt)
store "data_project.gdt"
# Open the clean project file
open "data_project.gdt"
# Print data and compute descriptive statistics
list L = UNRATE GDPC1
print L --byobs
summary L
# Summary for L using only data between 1980Q1 and 2007Q4
smpl 1980:1 2007:4
summary L
smpl UNRATE>4 && UNRATE <= 9.6 --restrict --replace
print L --byobs
summary L
smpl full
# Replace a specific value of UNRATE for observation 1981Q2:
UNRATE[1981:2] = 7.4
# Correlation
corr L
# Cross-correlation
xcorrgm L
# histogram
freq UNRATE
# Spectrum
pergm UNRATE
# Time-series plot
gnuplot L --with-lines=GDPC1 --with-impulses=UNRATE \
--time-series --output="/home/at/UHHDisk/AUS_Econ_Review_GRETL/figures/TSplot.png"
# Scatterplot + linear fit
gnuplot L --fit=linear --output="/home/at/UHHDisk/AUS_Econ_Review_GRETL/figures/XYplot.png"
# Boxplot factorized
series GreatModeration = (obs>="1985:1" && obs<="2007:4")
setinfo GreatModeration --description="1=Great Moderation, 0=otherwise"
boxplot UNRATE GreatModeration --factorized \
{ set title 'UNRATE outside + during Great Moderation' font ',16' ; } \
--output="/home/at/UHHDisk/AUS_Econ_Review_GRETL/figures/BOXplot.png"
# ARDL model Okuns's Law
series dU = UNRATE - UNRATE(-1)
series gY = 100*(GDPC1/GDPC1(-1) - 1)
print UNRATE dU GDPC1 gY --byobs
# Restrict the sample
smpl 1985:1 2007:4
/* ACTIVATE IFF WANTED
# Lag order
var 8 dU gY --lagselect
Model <- ols dU const dU(-1 to -2) gY(0 to -2)
series uhat = $uhat
gnuplot uhat --with-lines --time-series --output="/home/at/UHHDisk/AUS_Econ_Review_GRETL/figures/uhat.png"
modtest 1 --autocorr --quiet
modtest 4 --autocorr --quiet
modtest --white --quiet
reset --quiet
qlrtest --plot="/home/at/UHHDisk/AUS_Econ_Review_GRETL/figures/QLR.png"
# Multipliers
printf "Impact multiplier %g\n", $coeff(gY)
scalar lr = ($coeff(gY)+$coeff(gY_1)+$coeff(gY_2)) / (1-$coeff(dU_1)-$coeff(dU_2))
printf "Long-run m. %g\n", lr
##################################
# OLS using Gretl's matrix language
matrix Y = {dU} # takes eventually restricted sample into account
list xlist = const dU(-1 to -2) gY(0 to -2)
matrix X = {xlist}
bhat = inv(X'X)*X'Y
printf "%12.6g\n", bhat'
# Random vector to series
rvec = mrandgen(t, 14, $nobs, 10) # t(14)-distribution
series trandom = rvec[,2]
print trandom -o
*/
#####################
# VAR #
#####################
list ylist = dU gY # specify list of regressor
var 8 ylist --lagselect
Model <- var 2 ylist
modtest 4 --autocorr # test on 1st order serial correlation
modtest 4 --arch
modtest --normality
# IRF based on Cholesky
var 2 ylist --impulse-responses # print impulse responses
# VEVD based on Cholesky
var 2 ylist --variance-decomp # print variance decompositions
# Forecasting
fcast 2008:1 2018:2 --dynamic
# VAR in matrix form
matrix y = {dU}~{gY} # takes eventually restricted sample into account
list xlist = const dU(-1 to -2) gY(-1 to -2)
matrix X = {xlist}
bhat = inv(X'X)*X'y
bhat = bhat' # transpose k by 2 matrix
colnames(bhat, "const dU_1 dU_2 gY_1 gY_2")
rownames(bhat, "dU-eq: gY-eq:")
printf "%12.6g\n", bhat