Statalist The Stata Listserver


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

RE: st: aic and adftest -- error


From   "Olga Gorbachev Melloni" <[email protected]>
To   [email protected]
Subject   RE: st: aic and adftest -- error
Date   Thu, 31 Aug 2006 16:35:28 -0400

I appologize to all for posting previouse message before understanding what mata was. I now have it "fixed".

But my question is: is there anything like -adftest- for panel data?


I am using xtfisher. Which is great, but I would like to know how many lags are optimal.

-estat ic- doesn't work after xtfisher giving me "likelyhood info is not found in last estimation"
but i know that it exists, after typing -ereturn list- I see that e(ll_0) is defined.

do you have any advice?






From: "Olga Gorbachev Melloni" <[email protected]>
Reply-To: [email protected]
To: [email protected]
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/

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index