File: credscore.inp

package info (click to toggle)
gretl 2022c-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 59,552 kB
  • sloc: ansic: 409,074; sh: 4,449; makefile: 3,222; cpp: 2,777; xml: 599; perl: 364
file content (58 lines) | stat: -rw-r--r-- 1,451 bytes parent folder | download | duplicates (7)
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
# William Green's example of testing for heteroskedasticity,
# Econometric Analysis, 5e, chapter 11

open credscore.gdt

# select individuals with non-zero expenditures
smpl Avgexp > 0 --restrict

square Income
# basic OLS
list Xlist = Age OwnRent Income sq_Income
ols Avgexp 0 Xlist
# save squared residuals
u2 = $uhat^2
# White's standard errors
ols Avgexp 0 Xlist --robust --quiet
White = $stderr'
set hc_version 1
ols Avgexp 0 Xlist --robust --quiet
DM1 = $stderr'
set hc_version 2
ols Avgexp 0 Xlist --robust --quiet
DM2 = $stderr'
print "Robust standard error estimates"
printf "White's S.E.:\n%8.3f", White 
# Note: there's a typo in Greene's presentation of D and M(1)
printf "D and M (1):\n%8.3f", DM1
printf "D and M (2):\n%8.3f", DM2 

# White's test
modtest --white --quiet

set echo off
set messages off

# Breusch-Pagan test using just Income and its square
scalar s2 = sum(u2)/$T
series g = u2/s2
list BPlist = Income sq_Income
ols g 0 BPlist --quiet
series gdev = g - mean(g)
scalar TSS = sum(gdev*gdev)
scalar LM = .5*(TSS-$ess)
scalar df = nelem(BPlist)
printf "Breusch-Pagan   LM(%d) = %6.3f [%.3g]\n", df, LM, pvalue(X,df,LM)

# Koenker variant
scalar V = (1/$T)*sum((u2 - s2)^2)
g = u2 - s2
ols g 0 BPlist --quiet
gdev = g - mean(g)
TSS = sum(gdev*gdev)
scalar LMK = (TSS-$ess)/V
printf "Koenker-Bassett LM(%d) = %6.3f [%.3g]\n", df, LMK, pvalue(X,df,LMK)
printf "For df = %d, Chi-square(.05) = %.3f\n", df, critical(X,df,.05)