/usr/share/gretl/scripts/ps8-7.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 | # PS8.7, for Example 8.8 -- estimation of model by FGLS
open data8-1
genr LNSALARY=ln(SALARY)
# generate powers of YEARS for the various tests
genr YRS2 = YEARS*YEARS
genr YRS3 = YEARS*YRS2
genr YRS4 = YRS2*YRS2
# estimate log quadratic model by OLS
ols LNSALARY const YEARS YRS2
# save absolute value of uhat and uhat squared
genr absuhat=abs($uhat)
genr usq=$uhat*$uhat
# compute weights using the Glesjer test approach
ols absuhat const YEARS YRS2
# predict uhat as observed minus residual stored as uhat
genr absuhat1=absuhat-$uhat
print absuhat1
# luckily all estimated sigmas are positive and so apply WLS
genr wt1=1/(absuhat1^2)
wls wt1 LNSALARY const YEARS YRS2
# compute weights using the Breusch-Pagan test approach
ols usq const YEARS YRS2
/* predict uhat squared as observed uhat square minus residual
stored under the name uhat. Note that even though labelled as uhat,
it is really the residuals for uhat squared model */
genr usqhat1=usq-$uhat
# print estimated variance and note that 3 observations have negative
# values, which are unacceptable
print usqhat1
# replace these negative values with the original uhat squared values
genr d1=(usqhat1>0.0)
genr usqhat2=(d1*usqhat1) + ((1-d1)*usq)
print usqhat2
# compute weights and use FGLS which is also WLS
genr wt2=1/usqhat2
wls wt2 LNSALARY const YEARS YRS2
# compute weights using the White's test approach
ols usq const YEARS YRS2 YRS3 YRS4
genr usqhat3=usq-$uhat
# print estimated variance and note that this also has negative
# values, which are unacceptable
print usqhat3
# replace these negative values with the original uhat squared values
genr d2=(usqhat3>0.0)
genr usqhat4=(d2*usqhat3) + ((1-d2)*usq)
print usqhat4
# compute weights and use FGLS which is also WLS
genr wt3=1/usqhat4
wls wt3 LNSALARY const YEARS YRS2
# compute weights using the Harvey-Godfrey test approach
genr lnusq=ln(usq)
ols lnusq const YEARS YRS2
# save estimated ln(sigma square) and take antilog
genr lnusq1=lnusq-$uhat
genr usqhat5=exp(lnusq1)
# compute weights and use FGLS which is also WLS
genr wt4=1/usqhat5
wls wt4 LNSALARY const YEARS YRS2
|