Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Help in Programing


From   Ricardo Gon�alves Silva <[email protected]>
To   "Stata" <[email protected]>
Subject   st: Help in Programing
Date   Fri, 4 Mar 2005 16:07:50 -0300

Dear Users,

The folowing code is to implement a test for comtemporaneous correlation in
panel data, after xtreg ..., fe.
The statistic to be computed is: CD=sqrt(T/(N*(N-1))*pwc, where
T is the number of periods, N the panel dimension and pwc is the estimated
pair-wise residual correlation.
However, when I run it, I receive the error

. cdpesaran yr
the subcommand hold has been moved from estimates to  _estimates
r(198);


Any hint?

* cdpesaran V1.0 cloned from bpagan.ado %Ricardo Gon�alves Silva

program define cdpesaran, rclass

syntax varlist(ts min=1 numeric) [if] [in]


tempname res res2 ravg regest


marksample touse

if "`sample'" == "" { qui replace `touse' = 0 if !e(sample) }

/* fetch residuals */

qui predict `res' if `touse' , res

qui gen `res2' = `res'

summ `res2', meanonly

qui gen `ravg' = 1.0/r(mean)*`res2'


/* regress scaled squared residuals on regressorlist */

estimates hold `regest'

qui regress `ravg' `varlist' if `touse'

return scalar N = e(N)

return scalar cdpesaran = sqrt(ts/(N*(N-1))*e(mss)

return scalar df = e(df_m)

return scalar p = normprob(return(df),return(cdpesaran))


di " "

di in gr "Pesara CD LM statistic: " /*

*/ in ye %9.0g return(cdpesaran) in gr /*

*/ in gr " Normal(" %2.0f in ye return(df) /*

*/ ") P-value = " in ye %6.0g return(p)

di " "

end


exit



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.6.1 - Release Date: 4/3/2005


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