/usr/share/gretl/scripts/ps9-8.inp is in gretl-common 2017d-3build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | # PS9.8, ARCH estimation: Example 9.10 and Table 9.4
open data9-2
genr M1 = M(-1)
genr M2 = M(-2)
genr D1 = D(-1)
genr D2 = D(-2)
# estimate model
ols r const M1 M2 D1 D2
# generate uhat square and lags
genr usq = $uhat*$uhat
genr usq1 = usq(-1)
genr usq2 = usq(-2)
genr usq3 = usq(-3)
# estimate auxiliary regression for ARCH(3)
ols usq const usq1 usq2 usq3
# compute nRsquared and pvalue
genr LM1=$nrsq
pvalue X 3 LM1
# ARCH(3) is not supported but ARCH(1) term is significant at 9 percent
ols usq const usq1
genr LM2=$nrsq
# generate predicted variance as observed minus error uhat
genr usqhat = usq-$uhat
pvalue X 1 LM2
# all values of predicted variance are positive
print usqhat
# compute weights for WLS
genr wt=1/usqhat
# estimate model by weighted least squares
wls wt r const M1 M2 D1 D2
# compare shortcut command
arch 1 r const M1 M2 D1 D2
# omit D2 which has an insignificant coefficient
omit D2
|