Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: aic and adftest -- error


From   "Olga Gorbachev Melloni" <olga_gorbachev@hotmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: aic and adftest -- error
Date   Thu, 31 Aug 2006 16:09:58 -0400

Hi,

I liked very much the -adftest- routine that Rodrigo Martell posted a few weeksa ago. So i copied it hoping ot use it. But for whatever reason I get an error messge that the "varlist is not allowed" and of course if I don't give any varlist, the error message says "requires varlist"

does that make any sense?

adftest dfood, lag(5)

*****************
Here is the repreduction of the code I used:
*********************

program define adftest, rclass

version 9.2
syntax varlist(max=1) [if] [in] [, Lags(int-1) bic ]
estimates clear
tokenize `varlist'
foreach var of local varlist{
	forvalues i=1/`lags'{
		//display "ADF(`i') of `var'"
		qui dfuller `var', constant lags(`i') 		local list storage(`i')
		estimates store adf_`i'_`var'
	}
	qui estimates stats `storage(`i')'
	matrix s=r(S)
	matrix criteria=J(`lags',2,.)
	forvalues i=1/`lags' {
		matrix criteria[`i',1]=s[`i',5]
		matrix criteria[`i',2]=s[`i',6]
	}
if "`bic'" != "" {
	matrix criteria = criteria[1...,2]
	local crit  "BIC"
	}
else {
	matrix criteria = criteria[1...,1]
	local crit  "AIC"
	}
}

mata: min_row(st_matrix("criteria"))
local min = min[1,1]
display " "
display in gr "Optimal lag by `crit' criteria = " `min'
dfuller `varlist', lag(`min') constant

end

mata:
	matrix function min_row(matrix A)
	{
	B = colmin(A)
 	C = B:==A
 	A2 = (0, 0)
 	maxindex(C, 1, C, A2)
 	st_matrix("min",C)

 	}
end

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index