%eqname="eq01" 'please set the estimated equation name,
%maxlag = "12" 'maximum number of lags
%dep = "M2GR" 'please set the dependent variable name
%regs1 = "RGDPGR" 'independent variables name
%regs2 = "CPI"
%regs3 = "CREDITGR"
%criterion = "@AIC" ' "@AIC" for Akaike, "@schwarz" for Schwarz, and "@HQ" for Hannan-Quinn
!maxlag = @val(%maxlag) 'trans string to a value
close {%eqname} ' 不显示eq的估计结果
smpl @first @last
!mincrit = 1e10 '赋予初值
!x1lag=0
for !i=0 to !maxlag
!x1lag = !x1lag + !i
!x2lag=0
for !j=0 to !maxlag
!x2lag = !x2lag + !j
!x3lag=0
for !k=0 to !maxlag
!x3lag = !x3lag + !k
'estimate equation
equation {%eqname}.ls {%dep} {%regs1}(0 to -!x1lag) {%regs2}(0 to -!x2lag) {%regs3}(0 to -!x3lag) c
'capture criterion
if @upper(%criterion) = "@AIC" then
!crit = {%eqname}.@aic
endif
if @upper(%criterion) = "@SCHWARZ" then
!crit = {%eqname}.@schwarz
endif
if @upper(%criterion) = "@HQ" then
!crit = {%eqname}.@hq
endif
'compare criterion
if !crit < !mincrit then
!mincrit = !crit
!bestx1lag = !x1lag
!bestx2lag = !x2lag
!bestx3lag = !x3lag
endif
next
next
next
equation {%eqname}.ls {%dep} {%regs1}(0 to -!bestx1lag) {%regs2}(0 to -!bestx2lag) {%regs3}(0 to -!bestx3lag) c
show {%eqname}
matrix bestlags = @filledmatrix(!bestx1lag,!bestx2lag,!bestx3lag)


雷达卡



京公网安备 11010802022788号







