forked from burakbayramli/books
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Laglength.Src
39 lines (23 loc) · 835 Bytes
/
Laglength.Src
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
procedure laglength y start end laglength
TYPE SERIES y
TYPE INTEGER start end *laglength
option integer maxlag 1
local integer v1 v2 bestlag i
local real sbc sbcmin
inq(series=y) v1>>start v2>>end
lin(noprint) y v1+maxlag v2
# constant
compute sbcmin = %nobs*log(%rss) + (%nreg)*log(%nobs) , bestlag = 0
do i = 1,maxlag
lin(noprint) y v1+maxlag v2
# constant y{1 to i}
compute sbc = %nobs*log(%rss) + (%nreg)*log(%nobs)
if sbc < sbcmin ; compute bestlag = i , sbcmin = sbc
end do i
if bestlag.EQ.0 ; dis 'DO NOT USE LAGS'
if bestlag.GT.0
lin y v1+bestlag v2 ; # constant y{1 to bestlag}
if %defined(laglength) ; com laglength = bestlag
messagebox(style=yesno,status=status) 'Do you want to run a unit root test?'
if status.eq.1 ; @unit(lags=bestlag-1) y v1 v2
end laglength