/usr/share/gretl/scripts/ps8-8.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 | # PS8.8, for Application in Section 8.4
open data8-3
genr y=exphlth/pop
genr x=income/pop
# estimate model by OLS and save absolute residuals, squared residuals,
# and their logs
ols y const x seniors
genr absuhat=abs($uhat)
genr usq=$uhat*$uhat
genr lnusq=ln(usq)
# generate square and cross product variables; the flag -o generates cross
# product
square x seniors -o
# Testing and estimation for the Glesjer approach
ols absuhat const x seniors sq_x sq_seniors
# estimate residual s.d. from the auxiliary regression
genr sigmahat=absuhat-$uhat
# compute LM test statistic and its p-value
genr LM1=$nrsq
pvalue X 4 LM1
# print sigmahat and note that only one estimate is negative
print sigmahat
# replace negative value with original sigmahat and get weights
genr d1=(sigmahat>0.0)
genr sigma2=(d1*sigmahat)+((1-d1)*absuhat)
genr wt1=1/(sigma2^2)
# Estimate model by FGLS which is the same as WLS
wls wt1 y const x seniors
# Testing and estimation for the Breusch-Pagan approach
ols usq const x seniors sq_x sq_seniors
# estimate residual s.d. from the auxiliary regression
genr usqhat1=usq-$uhat
# compute LM test statistic and its p-value
genr LM2=$nrsq
pvalue X 4 LM2
# print usqhat and note that several estimates are negative
print usqhat1
# replace negative values with original usqhat and get weights
genr d2=(usqhat1>0.0)
genr usqhat2=(d2*usqhat1)+((1-d2)*usq)
genr wt2=1/usqhat2
# Estimate model by FGLS which is the same as WLS
wls wt2 y const x seniors
# Testing and estimation for White's procedure
ols usq const x seniors sq_x sq_seniors x_seniors
genr usqhat3=usq-$uhat
# compute LM test statistic and its p-value
genr LM3=$nrsq
pvalue X 5 LM3
# print usqhat and note that several estimates are negative
print usqhat3
# replace negative values with original usqhat and get weights
genr d3=(usqhat3>0.0)
genr usqhat4=(d3*usqhat3)+((1-d3)*usq)
genr wt3=1/usqhat4
# Estimate model by FGLS which is the same as WLS
wls wt3 y const x seniors
# Test using the Harvey-Godfrey approach
ols lnusq const x seniors sq_x sq_seniors
# compute LM test statistic and its p-value
genr LM4=$nrsq
# since the p-value is high, we do not reject homoscedasticity
pvalue X 4 LM4
# Because the coefficients for x and x-squared are significant, another LM
# test is done with just these
ols lnusq const x sq_x
genr lnusqhat=lnusq-$uhat
# compute LM test statistic and its p-value
genr LM5=$nrsq
pvalue X 2 LM5
# since the p-value is acceptable, we reject homoscedasticity and
# procede with WLS estimation
genr usqhat5=exp(lnusqhat)
genr wt4=1/usqhat5
wls wt4 y const x seniors
|