/usr/share/gretl/scripts/ps11-1.inp is in gretl-common 1.9.14-2.
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 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 | include criteria.gfn
# PS11.1 for fitting time trends in calwage
open data10-5.gdt
genr time
# create the square of time
genr tsq = time*time
# create the cube of time
genr t3 = tsq*time
# create inverse of time
genr invt = 1/time
# generate log of time
genr l_time = log(time)
# generate log of calwage
logs calwage
textplot calwage time
# set sample range to 1960-1989 and save 1990-1994 for predictions
smpl 1960 1989
# Note that the OLS estimates exhibit serial correlation
ols calwage 0 time
# linear Model A
ar1 calwage 0 time
# obtain one-step-ahead predicted values
fcast 1990 1994 yhata --static
# reset sample range
smpl 1990 1994
# regress actual against predicted
ols calwage 0 yhata
# compute prediction error, error sum of squares, and selection criteria
genr uhata = calwage - yhata
genr mapea = mean(100*abs(uhata)/calwage)
genr essa = sum(uhata*uhata)
criteria(essa, 5, 2)
# reset sample range to beginning
smpl 1960 1989
# quadratic Model B
ar1 calwage 0 time tsq
# obtain predicted value
fcast 1990 1994 yhatb --static
# reset sample range and regress actual against predicted calwage
smpl 1990 1994
ols calwage 0 yhatb
# compute prediction error, error sum of squares, and selection criteria
genr uhatb = calwage - yhatb
genr mapeb = mean(100*abs(uhatb)/calwage)
genr essb = sum(uhatb*uhatb)
criteria(essb, 5, 2)
smpl 1960 1989
# cubic Model C
ar1 calwage 0 time tsq t3
# obtain predicted value
fcast 1990 1994 yhatc --static
# reset sample range and regress actual against predicted calwage
smpl 1990 1994
ols calwage 0 yhatc
# compute prediction error, error sum of squares, and selection criteria
genr uhatc = calwage - yhatc
genr mapec = mean(100*abs(uhatc)/calwage)
genr essc = sum(uhatc*uhatc)
criteria(essc, 5, 2)
smpl 1960 1989
# linear-log Model D
ar1 calwage 0 l_time
# obtain predicted value
fcast 1990 1994 yhatd --static
# reset sample range and regress actual against predicted calwage
smpl 1990 1994
ols calwage 0 yhatd
# compute prediction error, error sum of squares, and selection criteria
genr uhatd = calwage - yhatd
genr maped = mean(100*abs(uhatd)/calwage)
genr essd = sum(uhatd*uhatd)
criteria(essd, 5, 2)
smpl 1960 1989
# reciprocal Model E
ar1 calwage 0 invt
# obtain predicted value
fcast 1990 1994 yhate --static
# reset sample range and regress actual against predicted calwage
smpl 1990 1994
ols calwage 0 yhate
# compute prediction error, error sum of squares, and selection criteria
genr uhate = calwage - yhate
genr mapee = mean(100*abs(uhate)/calwage)
genr esse = sum(uhate*uhate)
criteria(esse, 5, 2)
smpl 1960 1989
# log-linear Model F
ar1 l_calwage 0 time
# obtain predicted value
fcast 1990 1994 yhatf --static
smpl 1960 1994
# retrieve sigma squared from model E for bias correction
genr sgmasq = $ess/$df
genr yhatf = exp(yhatf+(sgmasq/2))
# reset sample range and regress actual against predicted calwage
smpl 1990 1994
ols calwage 0 yhatf
# compute prediction error, error sum of squares, and selection criteria
genr uhatf = calwage - yhatf
genr mapef= mean(100*abs(uhatf)/calwage)
genr essf = sum(uhatf*uhatf)
criteria(essf, 5, 2)
smpl 1960 1989
# double-log Model G
ar1 l_calwage 0 l_time
# obtain predicted value
fcast 1990 1994 yhatg --static
smpl 1960 1994
# retrieve sigma squared for model G
genr sgmasq = $ess/$df
# predict levels from model G
genr yhatg = exp(yhatg+(sgmasq/2))
smpl 1990 1994
# reset sample range and regress actual against predicted calwage
ols calwage 0 yhatg
# compute prediction error, error sum of squares, and selection criteria
genr uhatg = calwage - yhatg
genr mapeg = mean(100*abs(uhatg)/calwage)
genr essg = sum(uhatg*uhatg)
criteria(essg, 5, 2)
print -o calwage yhata yhatb yhatc yhatd yhate yhatf yhatg
print mapea mapeb mapec maped mapee mapef mapeg
|