Hi all
I am writing a programme where I would like the user to input a
variable for which they would like a test for heteroscedasticity. I
am trying to match that variable to a a corresponding e2var?q, then
generate a variable equal to that e2var?q which I will then use in
the heteroscedasticity test. I have tried so many things and what
follows is my lastest attempt. I suppose using the if statement
within the while loop may be a problem but I have tried various other
things. Any suggestions?
local k=2
while "``k''" ~= "" {
local kless1 = `k' - 1
tempvar e2var`kless1'q hetvar
ge `e2var`kless1'q' = `e2qq' * ``k'' `if'
if "`heteroscedasticity'" ~= "" { parse "`heteroscedasticity'",
parse(" ")
local namevar "`1'"
foreach var of varlist `varlist' {
if "`var'"=="``k''" {ge `hetvar'=`e2var`kless1'q'' `if'}
}
local k = `k'+1
}
.
.
.
.
if "`heteroscedasticity'" ~= "" {
quietly regress x y `hetvar' z `if' [`weight' `exp'], noconstant
if e(N) ~= `obs' { display "ERROR " e(N) "observations, when should
be " `obs' }
display in text "Heteroscedasticity w.r.t. `namevar'" _col(48) "{c
|}" %11.7f as result e(r2)*e(N) %18.7f chi2tail(1,e(r2)*e(N))
}
_______________________________________________
Miss Maureen Paul
Department of Economics
University of Warwick
Coventry CV4 7AL
UK
Phone: +44 (0)2476528418
Email: [email protected]
Web page: http://www.warwick.ac.uk/~ecrha/
*
* 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/