/usr/share/gretl/scripts/misc/armaloop.inp is in gretl-common 2016a-1.
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 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 | # Estimation of an ARMA(1,1) model "manually", using a
# loop construct.
open arma.gdt
scalar c = 0
scalar a = 0.1
scalar m = 0.1
series e = 0.0
series de_c = e
series de_a = e
series de_m = e
scalar crit = 1
loop while crit > 1.0e-9 --quiet
# one-step forecast errors
e = y - c - a*y(-1) - m*e(-1)
# log-likelihood
scalar loglik = -0.5 * sum(e^2)
print loglik
# partials of e wrt c, a, and m
de_c = -1 - m * de_c(-1)
de_a = -y(-1) -m * de_a(-1)
de_m = -e(-1) -m * de_m(-1)
# partials of l wrt c, a and m
series sc_c = -de_c * e
series sc_a = -de_a * e
series sc_m = -de_m * e
# OPG regression
ols const sc_c sc_a sc_m --print-final --no-df-corr --vcv
# Update the parameters
dc = $coeff(sc_c)
c += dc
da = $coeff(sc_a)
a += da
dm = $coeff(sc_m)
m += dm
printf " constant = %.8g (gradient = %#.6g)\n", c, dc
printf " ar1 coefficient = %.8g (gradient = %#.6g)\n", a, da
printf " ma1 coefficient = %.8g (gradient = %#.6g)\n", m, dm
crit = $T - $ess
print crit
endloop
scalar se_c = $stderr(sc_c)
scalar se_a = $stderr(sc_a)
scalar se_m = $stderr(sc_m)
set echo off
print ""
printf "constant = %.8g (se = %#.6g, t = %.4f)\n", c, se_c, c/se_c
printf "ar1 coefficient = %.8g (se = %#.6g, t = %.4f)\n", a, se_a, a/se_a
printf "ma1 coefficient = %.8g (se = %#.6g, t = %.4f)\n", m, se_m, m/se_m
# compare with the built-in arma command (conditional ML)
arima 1 0 1 ; y --conditional
|