Statalist


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

st: RE: Program ADF test with Perron's procedure


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Program ADF test with Perron's procedure
Date   Wed, 3 Oct 2007 14:54:19 +0100

Although 

syntax varname

is fine as a variant on 

syntax varlist

-syntax- still populates the -varlist- 
macro with whatever you supplied
as varname. No local macro -varname-
is defined by -syntax-. 

Thus I guess that 

qui dfuller `varname',

should be 

qui dfuller `varlist',

A separate bug in your program is 
that you allow -if- and -in- but 
do nothing to let them take effect. 
Various commands need to be made 

... if `touse' 

Another bug is 

local i Lags

which should be 

local i = `lags' 

Another class of bugs is confusion between tstat 
and `tstat', etc. And there are some typos. 

I note tacit assumptions about what your variables 
are called (DL*). 

Here is a hack. 

capture program drop adfperron
* NJC was here 
*! adfperron v1 Nourry 03oct2007
program adfperron, rclass
	version 9.2
	syntax varname(ts) [if] [in] [,Lags(int -1)]
	marksample touse
	qui count if `touse' 
	if r(N) == 0 error 2000 

	local i = `lags' 
	qui dfuller `varlist' if `touse', lags(`i') trend regress 
	*/first regression with i lags/

	local bstat = _b[DL`i']
	local sestat = _se[DL`i']
	local tstat = `bstat'/`sestat'

	*/computation of the t-stat of the 8th lag/

 	qui while abs(`tstat')< 1.645 & `i' > 0 {
		local i = `i' - 1
 		dfuller `varlist' if `touse', lags(`i') trend regress
 		local bstat = _b[DL`i']
 		local sestat = _se[DL`i']
 		local tstat = `bstat'/`sestat'
 /* while the last lag is not significant, drop it and
 do a new regression without this term */
 	}

	dfuller `varlist' if `touse', lags(`i') trend regress
end

Nick 
[email protected] 

Myriam Nourry

 I am trying to write a program to test unit root (ADF
> test) by using Perron's procedure to choose the
> maximum lag length included in the regression.
> 
> The idea is to perform a first regression with 8 lags.
> If the absolute value of the t-statistic on the eighth
> lagged term is less than -1,645 (i.e., approximate 5%
> significance level in an asymptotic normal
> distribution), then this term is dropped and the
> procedure is repeated for the seventh lagged term. The
> procedure is stopped when the last lagged term is
> significant, in which case all lesser
> first-differenced lagged terms remain in the test, or
> zero lagged terms will result.
> 
> Therefore, I wrote the following program (this is my
> first program...) but it doesn't work and I can't see
> the errors. So I need your help !
> 
> capture program drop adfperron
> *! adfperron v1 Nourry 03oct2007
> program define adfperron, rclass
> version 9.2
> syntax varname(ts) [if] [in] [,Lags(int -1)]
> marksample touse
> 
> local i Lags
> qui dfuller `varname', lags(`i') trend regress 
> */first regression with i lags/
> local bstat = "_b[DL`i']" 
> local sestat = "_se[DL`i']"
> gen tstat = `bstat'/`sestat'
> */computation of the t-stat of the 8th lag/
> 	while abs(`tstat')< abs(-1.645) & `i'>0 {
> 	local i=`i'-1
> 		qui dfuller `varname', lags(`i') trend regress
> 		qui replace bstat = "_b[DL`i']"
> 		qui replace sestat = "_se[DL`i']"
> 		qui replace tstat = `bstat'/`sestat'
> */while the last lag is not significant, drop it and
> do a new regression without this term/
> 		}
> dfuller `varname', lags(`i') trend regress
> end
> 
> When I run this program on Stata, I obtain the
> following message : `invalid name r(198)
> 
> I hope you can help me to solve this problem.

*
*   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